|
Application Programming: Files and Input/Output |
|
IDL on all platforms is able to read and write data from files up to 231-1 bytes in length. On some platforms, it is also able to read and write data from files longer than this limit.
To see if IDL on your platform supports large files, use the following:
PRINT, !VERSION.FILE_OFFSET_BITS
If IDL prints the number 64, the platform supports large files. For more information, see !VERSION.
| Warning Macintosh systems that use the UNIX File System (UFS) rather than the default Mac OS Extended Filesystem (HFS+) will not be able to access large files, even though IDL itself will report the ability to do so. This is a limitation of the file system, not of IDL. |
When reading and writing to files smaller than this limit, there is no difference in behavior between the platforms that can and those that cannot handle larger files. IDL uses longword integers for file position arguments (e.g. POINT_LUN, FSTAT) and keywords, as before. However, when dealing with files that exceed this limit, IDL uses signed 64-bit integers in order to be able to properly represent the offset. Consider the following example:
;Open the file OPENW, 1, 'test.dat' ;Initial position should be 0. POINT_LUN, -1, POS ;Print the position and its type. HELP, POS ;Move the file pointer past the signed 32-bit boundary. POINT_LUN, 1, '000000ffffffffff'x ;The position is now too large to represent as a longword. POINT_LUN, -1, POS ;Print the position and its type. HELP, POS CLOSE, 1
Executing these statements results in the following output:
POS LONG = 0 POS LONG64 = 1099511627775
Initially, the file position is 0, which fits easily into a 32-bit integer. Once the file position exceeds the range of a signed 32-bit number, IDL automatically shifts to the 64-bit integer type.
There are limitations on IDL's support for very large files that must be understood by the IDL programmer:
To see if your platform is 32- or 64-bit, use the following:
PRINT, !VERSION.MEMORY_BITS
IF "32" is returned, your platform is 32-bit. If "64" is returned, your platform is 64-bit. For more information, see !VERSION.
IDL Online Help (March 06, 2007)