Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Computer file
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== File operations == The most basic operations that programs can perform on a file are: * Create<!--needs a link--> a new file * Change the [[file system permissions|access permissions]] and [[file attribute|attributes]] of a file * [[open (system call)|Open]] a file, which makes the file contents available to the program * [[read (system call)|Read]] data from a file * [[write (system call)|Write]] data to a file * [[file deletion|Delete]] a file * [[close (system call)|Close]] a file, terminating the association between it and the program * [[truncation|Truncate]] a file, shortening it to a specified size within the file system without rewriting any content * Allocate space to a file without writing any content. Not supported by some file systems.<ref>fallocate(1)</ref> Files on a computer can be created, moved, modified, grown, shrunk ([[Truncation#Causes of truncation|truncated]]), and deleted. In most cases, computer programs that are executed on the computer handle these operations, but the user of a computer can also manipulate files if necessary. For instance, [[Microsoft Word]] files are normally created and modified by the Microsoft Word program in response to user commands, but the user can also move, [[rename (computing)|rename]], or [[File deletion|delete]] these files directly by using a [[file manager|file manager program]] such as [[Windows Explorer]] (on Windows computers) or by [[command-line interface|command lines]] (CLI). In [[Unix-like]] systems, [[user space]] programs do not operate directly, at a low level, on a file. Only the [[Kernel (operating system)|kernel]] deals with files, and it handles all user-space interaction with files in a manner that is transparent to the user-space programs. The [[operating system]] provides a level of [[Abstraction (computer science)|abstraction]], which means that interaction with a file from user-space is simply through its filename (instead of its [[inode]]). For example, <kbd>[[rm (Unix)|rm]] ''filename''</kbd> will not delete the file itself, but only a [[hard link|link]] to the file. There can be many links to a file, but when they are all removed, the [[Kernel (operating system)|kernel]] considers that file's memory space free to be reallocated. This [[Data remanence|free space]] is commonly considered a security risk (due to the existence of [[File recovery|file recovery software]]). Any secure-deletion program uses kernel-space (system) functions to wipe the file's data. File moves within a file system complete almost immediately because the data content does not need to be rewritten. Only the paths need to be changed. === Moving methods === There are two distinct implementations of file moves. When moving files between devices or partitions, some file managing software deletes each selected file from the source directory '''individually''' after being transferred, while other software deletes '''all files at once''' only after every file has been transferred. With the <code>[[mv (Unix)|mv]]</code> command for instance, the former method is used when selecting files individually, possibly with the use of [[wildcard character|wildcards]] (example: <code>mv -n sourcePath/* targetPath</code>, while the latter method is used when selecting entire directories (example: <code>mv -n sourcePath targetPath</code>). Microsoft [[Windows Explorer]] uses the former method for [[mass storage]] file moves, but the latter method using [[Media Transfer Protocol]], as described in {{section link|Media Transfer Protocol|File move behavior}}. The former method (individual deletion from source) has the benefit that space is released from the source device or partition imminently after the transfer has begun, meaning after the first file is finished. With the latter method, space is only freed after the transfer of the entire selection has finished. If an incomplete file transfer with the latter method is aborted unexpectedly, perhaps due to an unexpected power-off, system halt or disconnection of a device, no space will have been freed up on the source device or partition. The user would need to merge the remaining files from the source, including the incompletely written (truncated) last file. With the individual deletion method, the file moving software also does not need to cumulatively keep track of all files finished transferring for the case that a user manually aborts the file transfer. A file manager using the latter (afterwards deletion) method will have to only delete the files from the source directory that have already finished transferring.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)