Set the backup mode
Int_Type BACKUP_BY_COPYING
If non-zero, backup files will be made by copying the original file
to the backup file. If zero, the backup file will be created by
renaming the original file to the backup file. The default for
BACKUP_BY_COPYING
is zero because it is fastest.
rename_file, copy_file
IsHPFSFileSystem
Integer IsHPFSFileSystem(String path);
Returns non-zero if drive of path
(possibly the default drive) is
HPFS.
change_default_dir
Integer change_default_dir (String new_dir);
This function may be used to change the current working directory
of the editor to new_dir
. It returns zero upon success or -1
upon
failure.
Note: Each buffer has its own working directory. This function does not
change the working directory of the buffer. Rather, it changes the
working directory of the whole editor. This has an effect on functions
such as rename_file
when such functions are passed relative filenames.
setbuf_info, getbuf_info, rename_file
copy_file
Integer copy_file (String src, String dest);
This function may be used to copy a file named src
to a new file
named dest
. It attempts to preserve the file access and modification
times as well as the ownership and protection.
It returns 0
upon success and -1
upon failure.
rename_file, file_status
delete_file
Integer delete_file (String file);
This function may be used to delete a file specified by the file
parameter. It returns non-zero if the file was sucessfully deleted
or zero otherwise.
rmdir
directory
returns number of files and list of files which match filename. On unix, this defaults to filename*. It is primarily useful for DOS and VMS to expand wildcard filenames
expand_filename
String expand_filename (String file);
The expand_filename
function expands a file to a canonical form.
For example, under Unix, if file
has the value "/a/b/../c/d"
, it
returns "/a/c/d"
. Similarly, if file
has the value
"/a/b/c//d/e"
, "/d/e"
is returned.
extract_filename
String extract_filename (String filespec);
This function may be used to separate the file name from the path of
of a file specified by filespec
. For example, under Unix, the
expression
extract_filename ("/tmp/name");
returns the string "name"
.
expand_filename
file_changed_on_disk
Integer file_changed_on_disk (String fn);
This function may be used to determine if the disk file specified by the
parameter fn
is more recent than the current buffer.
file_time_compare, check_buffers
file_status
Integer file_status (String filename);
The file_status
function returns information about a file specified
by the name filename
. It returns an integer describing the file
type:
2 file is a directory
1 file exists and is not a directory
0 file does not exist.
-1 no access.
-2 path invalid
-3 unknown error
file_time_compare
Integer file_time_cmp (String file1, String file2);
This function compares the modification times of two files,
file1
and file2
. It returns an integer that is either
positive, negative, or zero integer for file1 > file2
,
file1 < file2
, or file1 == file2
, respectively. In
this context, the comparison operators are comparing file
modification times. That is, the operator >
should be read
``is more recent than''. The convention adopted by this routine is
that if a file does not exist, its modification time is taken to be
at the beginning of time. Thus, if f
exists, but g
does
not, the file_time_compare (f, g)
will return a positive
number.
file_status, time
find_file
Integer find_file (String name);
The find_file
function switches to the buffer associated with the
file specified by name
. If no such buffer exists, one is created
and the file specified by name
is read from the disk and associated
with the new buffer. The buffer will also become attached to the
current window. Use the read_file
function to find a file but not
associate it with the current window.
read_file
insert_file
Integer insert_file (String f);
This function may be used to insert the contents of a file named f
into the buffer at the current position. The current editing point
will be placed at the end of the inserted text. The function returns
-1
if the file was unable to be opened; otherwise it returns the
number of lines inserted. This number can be zero if the file is empty.
read_file, find_file, insert
msdos_fixup_dirspec
String msdos_fixup_dirspec (String dir);
The motivation behind this is that DOS does not like a trailing
backslash except if it is for the root dir. This function makes
dir
conform to that.
read_file
Integer read_file (string fn);
The read_file
function may be used to read a file specified by fn
into its own buffer. It returns a non-zero value upon success and
signals an error upon failure. The hook find_file_hook
is called
after the file is read in. Unlike the related function, find_file
,
this function does not create a window for the newly created buffer.
find_file, file_status, write_buffer
rename_file
Integer rename_file (String old_name, String new_name);
This function may be used to change the name of a disk file from
old_name
to new_name
. Upon success, zero is returned. Any other
value indicates failure.
Note: Both filenames must refer to the same file system.
file_status, stat_file
set_file_translation
set_file_translation (Integer n);
This function affects only the way the next file is opened. Its affect does not last beyond that. If it the value of the parameter is 1, the next file will be opened in binary mode. If the parameter is zero, the file will be opened in text mode.