# file-op(2)

[Home] [Commands] [Variables] [Macro-Dev] [Glossary]

## NAME

file-op - File system operations command

## SYNOPSIS

n file-op [ ( [ "from-file" "to-file" ] ) |

( ["delete-file"] ) | ( ["dir-name"] ) |
( [ "chmod-file" "mode" ] ) ]

## DESCRIPTION

file-op can be used to perform numerous file system operations. The given argument n must be used to determine the required operation, the value is a bit based flag denoting the operation as follows:

0x010

Log-off and close down the current ftp connect (not a file system operation but functionality was required and it had to go somewhere).

0x020

When this bit is set the command functionality is changed to delete-file, the single argument delete-file is deleted. Note this can also delete a directory if the directory is empty.

0x040

When this bit is set the command functionality is changed to move-file, the specified from-file is moved to to-file.

0x080

When this bit is set the command functionality is changed to copy-file, the specified from-file is copied to to-file.

0x100

When this bit is set the command functionality is changed to making a new directory, the specified dir-name is the name of the new directory. A file or directory of the given name must not already exist.

0x200

When this bit is set the command functionality is changed to a change mode type of operation. chmod-file is the name of the file (or directory) to change and mode is the integer mode to apply. Note that the mode value is operating system specific. The file attributes may be retrieved with the &stat(4) command.

Only one operation can be performed per invocation. The following bits in the given argument n can be used to effect the behaviour of these operations:

0x01

Enables validity checks, these include a check that the proposed file does not already exist, if so confirmation of writing is requested from the user. Also MicroEmacs checks all other current buffers for one with the proposed file name, if found, again confirmation is requested. Without this flag the command will always succeed wherever possible.

0x02

Creates a backup of any file about to be deleted or over-written. Set help on $buffer-backup(5) for backup file-name generation.

0x04

When validity checks are enabled (see bit 0x01 above) and this bit is set, if a problem is found the command aborts rather than prompting the user. Also see the error return codes in the notes section below.

0x80

When this bit is set then the files time stamp is preserved.

## NOTES

http files are not supported except as the source file when copying. ftp files are fully supported with the restriction that the from and to files cannot both be url (http or ftp) files. The one exception to this is when moving a file on the same ftp site in which case ME will attempt to use an ftp rename command.

The command is used by file-browser(3) and ftp(3) which provides an easy to use interfaces for file manipulation.

When the command fails an error code is returned in the $result(5) variable, which will be one of the following:

0

User aborted.

1

General error.

2

Failure due to a read error.

3

Failure due to a write error.

4

Failure due to a directory creation error.

5

Failure due to a file or directory deletion error.

6

Failure due to file write checks, i.e. file already exists etc.

7

Failure due to directory creation checks, i.e. the directory or file already exists.

8

Failure due to file delete checks, i.e. file is read only.

9

Failure due to source and destination files are URLs.

## SEE ALSO

file-browser(3), ftp(3), find-file(2), write-buffer(2), &stat(4), $result(5), $temp-name(5).

(c) Copyright JASSPA 2009
Last Modified: 2009/09/02
Generated On: 2009/10/12

</HMTL>