|
| iMatix home page | << | < | > | >> |
SFLVersion 2.11 |
#include "sflfile.h"
Bool
safe_to_extend (
const char *filename)
Handles system-specific case of extending a file that may not be in a valid state for such an operation. Returns TRUE if the extend can go ahead; returns FALSE if the extend cannot be permitted. Under MS-DOS and Windows, if the last byte in the file is Ctrl-Z (26) the file is truncated by 1 position to remove this character.
{
#if (defined (MSDOS_FILESYSTEM))
int handle; /* Opened file handle */
char endoffile; /* Last character in file */
ASSERT (filename);
if (system_devicename (filename))
return (FALSE); /* Not allowed on device names */
handle = open (filename, O_RDWR + O_BINARY, S_IREAD | S_IWRITE);
if (handle) /* If not found, ignore */
{
lseek (handle, -1, SEEK_END);
read (handle, &endoffile, 1);
if (endoffile == 26)
chsize (handle, filelength (handle) - 1);
close (handle);
}
#endif
return (TRUE);
}
| | << | < | > | >> |
|