input = history_filename (filename);
file = open (input, O_RDONLY|O_BINARY, 0666);
+
+#ifdef __MSDOS__
+ /* MSDOS doesn't allow leading dots in file names. Try again
+ with the dot replaced by an underscore. */
+ if (file < 0 && !filename)
+ {
+ input[strlen (input) - 8] = '_';
+ file = open (input, O_RDONLY|O_BINARY, 0666);
+ }
+#endif
if ((file < 0) || (fstat (file, &finfo) == -1))
goto error_and_exit;
}
buffer = xmalloc (file_size + 1);
+#if 0
if (read (file, buffer, file_size) != file_size)
+#else
+ if (read (file, buffer, file_size) < 0)
+#endif
{
error_and_exit:
if (file >= 0)
int
history_truncate_file (fname, lines)
char *fname;
- register int lines;
+ int lines;
{
register int i;
int file, chars_read;
filename = history_filename (fname);
file = open (filename, O_RDONLY|O_BINARY, 0666);
+#ifdef __MSDOS__
+ /* MSDOS doesn't allow leading dots in file names. Try again
+ with the dot replaced by an underscore. */
+ if (file < 0 && !fname)
+ {
+ filename[strlen (filename) - 8] = '_';
+ file = open (filename, O_RDONLY|O_BINARY, 0666);
+ }
+#endif
+
if (file == -1 || fstat (file, &finfo) == -1)
goto truncate_exit;
if (i && ((file = open (filename, O_WRONLY|O_TRUNC|O_BINARY, 0600)) != -1))
{
write (file, buffer + i, file_size - i);
+
+#if defined (__BEOS__)
+ /* BeOS ignores O_TRUNC. */
+ ftruncate (file, file_size - i);
+#endif
+
close (file);
}
if ((file = open (output, mode, 0600)) == -1)
{
+#ifdef __MSDOS__
+ /* MSDOS doesn't allow leading dots in file names. If this is
+ the default file name, try again with the dot replaced by an
+ underscore. */
+ if (!filename)
+ {
+ output[strlen (output) - 8] = '_';
+ if ((file = open (output, mode, 0600)) == -1)
+ {
+ FREE (output);
+ return (errno);
+ }
+ }
+#else
FREE (output);
return (errno);
+#endif
}
if (nelements > history_length)