Oct 95 Tips
Volume Number: 11
Issue Number: 10
Column Tag: Tips & Tidbits
Tips & Tidbits
By Steve Sisak, Contributing Editor
Note: Source code files accompanying article are located on MacTech CD-ROM or
source code disks.
TIP OF THE MONTH
Spotting the Elusive Ram Disk
Here is a handy function for performing a dynamic check for the existence of a
RAM disk as created by Apple’s Memory control panel. I use it in some of my programs
when speed is paramount. Since the user can remove the RAM disk at any time by
turning it off from the Memory control panel, and can rename it at any time, the code
here must be called before using the RAM disk. In other words, don’t check just once
during your application startup and assume thereafter that it will still be there, check
before each access if possible. Program defensively...
- Greg Poole
HasRamDisk.h
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
extern Boolean HasRamDisk( FSSpecPtr ramDiskSpec );
#ifdef __cplusplus
}
#endif
HasRamDisk.c
/******************************************************************************
HasRamDisk.c
A dynamic check for the existence of a RAM disk as created by Apple's
Memory control panel. Since the user can remove the RAM disk at any time
by turning it off from the Memory control panel, and can rename it at any
time, the code here needs to be called before assuming the existence of
a RAM disk. In other words, don't check just once during your application
startup and assume thereafter that it will still be there, check
before each access. Program defensively...