Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Computer file

From Wikipedia, the free encyclopedia
Computer resource for recording data on a storage device
This articleneeds additional citations forverification. Please helpimprove this article byadding citations to reliable sources. Unsourced material may be challenged and removed.
Find sources: "Computer file" – news ·newspapers ·books ·scholar ·JSTOR
(June 2009) (Learn how and when to remove this message)

Acomputer file is a collection ofdata on acomputer storage device, primarily identified by itsfilename. Just as words can be written on paper, so too can data be written to a computer file. Files can be shared with and transferred betweencomputers andmobile devices viaremovable media,networks, or theInternet.

Differenttypes of computer files are designed for different purposes. A file may be designed to store a written message, a document, aspreadsheet, animage, avideo, aprogram, or any wide variety of other kinds of data. Certain files can store multiple data types at once.

By using computer programs, a person can open, read, change, save, and close a computer file. Computer files may be reopened, modified, andcopied an arbitrary number of times.

Files are typically organized in afile system, which tracks file locations on the disk and enables user access.

Etymology

[edit]
Apunched card file
The twindisk files of anIBM 305 system

The word "file" derives from the Latinfilum ("a thread, string").[1]

"File" was used in the context of computer storage as early as January 1940. InPunched Card Methods in Scientific Computation,[2] W. J. Eckert stated, "The first extensive use of the early Hollerith Tabulator in astronomy was made byComrie.[3] He used it for building a table from successive differences, and for adding large numbers of harmonic terms". "Tables offunctions are constructed from their differences with great efficiency, either as printed tables or as afile of punched cards."

In February 1950, in aRadio Corporation of America (RCA) advertisement inPopular Science magazine[4] describing a new "memory" vacuum tube it had developed, RCA stated: "the results of countless computations can be kept 'on file' and taken out again. Such a 'file' now exists in a 'memory' tube developed at RCA Laboratories. Electronically it retains figures fed into calculating machines, holds them in storage while it memorizes new ones – speeds intelligent solutions through mazes of mathematics."

In 1952, "file" denoted, among other things, information stored onpunched cards.[5]

In early use, the underlying hardware, rather than the contents stored on it, was denominated a "file". For example, theIBM 350 disk drives were denominated "disk files".[6] The introduction,c. 1961, by theBurroughs MCP and the MITCompatible Time-Sharing System of the concept of a "file system" that managed several virtual "files" on one storage device is the origin of the contemporary denotation of the word. Although the contemporary "register file" demonstrates the early concept of files, its use has greatly decreased.

File contents

[edit]

On most modernoperating systems, files are organized into one-dimensional arrays ofbytes. Theformat of a file is defined by its content since a file is solely a container for data.

On some platforms the format is indicated by itsfilename extension, specifying the rules for how the bytes must be organized and interpreted meaningfully. For example, the bytes of a plain text file (.txt in Windows) are associated with eitherASCII orUTF-8 characters, while the bytes of image, video, and audio files are interpreted otherwise. Most file types also allocate a few bytes formetadata, which allows a file to carry some basic information about itself.

Some file systems can store arbitrary (not interpreted by the file system) file-specific data outside of the file format, but linked to the file, for exampleextended attributes orforks. On other file systems this can be done viasidecar files or software-specific databases. All those methods, however, are more susceptible to loss of metadata thancontainer andarchive file formats.

File size

[edit]
This sectionmay have misleading content. Please helpclarify the content.(March 2019)
Main article:File size

At any instant in time, a file has a specific size, normally expressed as a number ofbytes,[a] that indicates how much storage is occupied by the file. In most modern operating systems the size can be any non-negative whole number of bytes up to a system limit. Many older operating systems kept track only of the number ofblocks ortracks occupied by a file on a physical storage device. In such systems, software employed other methods to track the exact byte count (e.g.,CP/M used a special control character,Ctrl-Z, to signal the end of text files).

The general definition of a file does not require that its size have any real meaning, however, unless the data within the file happens to correspond to data within a pool of persistent storage. A special case is azero byte file; these files can be newly created files that have not yet had any data written to them, or may serve as some kind offlag in the file system, or are accidents (the results of aborted disk operations). For example, the file to which the link/bin/ls points in a typicalUnix-like system probably has a defined size that seldom changes. Compare this with/dev/null which is also a file, but as acharacter special file, its size is not meaningful.

Organization of data in a file

[edit]

Information in a computer file can consist of smaller packets of information (often called "records" or "lines") that are individually different but share some common traits. For example, a payroll file might contain information concerning all the employees in a company and their payroll details; each record in the payroll file concerns just one employee, and all the records have the common trait of being related to payroll—this is very similar to placing all payroll information into a specific filing cabinet in an office that does not have a computer. A text file may contain lines of text, corresponding to printed lines on a piece of paper. Alternatively, a file may contain an arbitrary binary image (ablob) or it may contain anexecutable.

The way information is grouped into a file is entirely up to how it is designed. This has led to a plethora of more or less standardized file structures for all imaginable purposes, from the simplest to the most complex. Most computer files are used bycomputer programs which create, modify or delete the files for their own use on an as-needed basis. The programmers who create the programs decide what files are needed, how they are to be used and (often) their names.

In some cases, computer programs manipulate files that are made visible to the computer user. For example, in aword-processing program, the user manipulates document files that the user personally names. Although the content of the document file is arranged in a format that the word-processing program understands, the user is able to choose the name and location of the file and provide the bulk of the information (such as words and text) that will be stored in the file.

Many applications pack all their data files into a single file called anarchive file, using internal markers to discern the different types of information contained within. The benefits of the archive file are to lower the number of files for easier transfer, to reduce storage usage, or just to organize outdated files. The archive file must often be unpacked before next using.

File operations

[edit]

The most basic operations that programs can perform on a file are:

  • Create a new file
  • Change theaccess permissions andattributes of a file
  • Open a file, which makes the file contents available to the program
  • Read data from a file
  • Write data to a file
  • Delete a file
  • Close a file, terminating the association between it and the program
  • 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.[7]

Files on a computer can be created, moved, modified, grown, shrunk (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, ordelete these files directly by using afile manager program such asWindows Explorer (on Windows computers) or bycommand lines (CLI).

InUnix-like systems,user space programs do not operate directly, at a low level, on a file. Only thekernel deals with files, and it handles all user-space interaction with files in a manner that is transparent to the user-space programs. Theoperating system provides a level ofabstraction, which means that interaction with a file from user-space is simply through its filename (instead of itsinode). For example,rmfilename will not delete the file itself, but only alink to the file. There can be many links to a file, but when they are all removed, thekernel considers that file's memory space free to be reallocated. Thisfree space is commonly considered a security risk (due to the existence offile 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

[edit]

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 directoryindividually after being transferred, while other software deletesall files at once only after every file has been transferred.

With themv command for instance, the former method is used when selecting files individually, possibly with the use ofwildcards (example:mv -n sourcePath/* targetPath, while the latter method is used when selecting entire directories (example:mv -n sourcePath targetPath). MicrosoftWindows Explorer uses the former method formass storage file moves, but the latter method usingMedia Transfer Protocol, as described inMedia 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.

Identifying and organizing

[edit]
Files and folders arranged in a hierarchy

In modern computer systems, files are typically accessed using names (filenames). In some operating systems, the name is associated with the file itself. In others, the file is anonymous, and is pointed to by links that have names. In the latter case, a user can identify the name of the link with the file itself, but this is a false analogue, especially where there exists more than one link to the same file.

Files (or links to files) can be located in directories. However, more generally, adirectory can contain either a list of files or a list of links to files. Within this definition, it is of paramount importance that the term "file" includes directories. This permits the existence of directory hierarchies, i.e., directories containing sub-directories. A name that refers to a file within a directory must be typically unique. In other words, there must be no identical names within a directory. However, in some operating systems, a name may include a specification of type that means a directory can contain an identical name for more than one type of object such as a directory and a file.

In environments in which a file is named, a file's name and the path to the file's directory must uniquely identify it among all other files in the computer system—no two files can have the same name and path. Where a file is anonymous, named references to it will exist within a namespace. In most cases, any name within the namespace will refer to exactly zero or one file. However, any file may be represented within any namespace by zero, one or more names.

Any string of characters may be a well-formed name for a file or a link depending upon the context of application. Whether or not a name is well-formed depends on the type of computer system being used. Early computers permitted only a few letters or digits in the name of a file, but modern computers allow long names (some up to 255 characters) containing almost any combination ofUnicode letters or Unicode digits, making it easier to understand the purpose of a file at a glance. Some computer systems allow file names to contain spaces; others do not. Case-sensitivity of file names is determined by thefile system. Unix file systems are usually case sensitive and allow user-level applications to create files whose names differ only in the case of characters.Microsoft Windows supports multiple file systems, each with different policies[which?] regarding case-sensitivity. The commonFAT file system can have multiple files whose names differ only in case if the user uses adisk editor to edit the file names in thedirectory entries. User applications, however, will usually not allow the user to create multiple files with the same name but differing in case.

Most computers organize files into hierarchies using folders, directories, or catalogs. The concept is the same irrespective of the terminology used. Each folder can contain an arbitrary number of files, and it can also contain other folders. These other folders are referred to as subfolders. Subfolders can contain still more files and folders and so on, thus building a tree-like structure in which one "master folder" (or "root folder" — the name varies from one operating system to another) can contain any number of levels of other folders and files. Folders can be named just as files can (except for the root folder, which often does not have a name). The use of folders makes it easier to organize files in a logical way.

When a computer allows the use of folders, each file and folder has not only a name of its own, but also a path, which identifies the folder or folders in which a file or folder resides. In the path, some sort of special character—such as a slash—is used to separate the file and folder names. For example, in the illustration shown in this article, the path/Payroll/Salaries/Managers uniquely identifies a file calledManagers in a folder calledSalaries, which in turn is contained in a folder calledPayroll. The folder and file names are separated by slashes in this example; the topmost or root folder has no name, and so the path begins with a slash (if the root folder had a name, it would precede this first slash).

Many computer systems useextensions in file names to help identify what they contain, also known as the file type. On Windows computers, extensions consist of a dot (period) at the end of a file name, followed by a few letters to identify the type of file. An extension of.txt identifies a text file; a.doc extension identifies any type of document or documentation, commonly in theMicrosoft Wordfile format;and so on. Even when extensions are used in a computer system, the degree to which the computer system recognizes and heeds them can vary; in some systems, they are required, while in other systems, they are completely ignored if they are presented.

Protection

[edit]

Many modern computer systems provide methods for protecting files against accidental and deliberate damage. Computers that allow for multiple users implementfile permissions to control who may or may not modify, delete, or create files and folders. For example, a given user may be granted only permission to read a file or folder, but not to modify or delete it; or a user may be given permission to read and modify files or folders, but not to execute them. Permissions may also be used to allow only certain users to see the contents of a file or folder. Permissions protect against unauthorized tampering or destruction of information in files, and keep private information confidential from unauthorized users.

Another protection mechanism implemented in many computers is aread-only flag. When this flag is turned on for a file (which can be accomplished by a computer program or by a human user), the file can be examined, but it cannot be modified. This flag is useful for critical information that must not be modified or erased, such as special files that are used only by internal parts of the computer system. Some systems also include ahidden flag to make certain files invisible; this flag is used by the computer system to hide essential system files that users should not alter.

Storage

[edit]

Any file that has any useful purpose must have some physical manifestation. That is, a file (an abstract concept) in a real computer system must have a real physical analogue if it is to exist at all.

In physical terms, most computer files are stored on some type of data storage device. For example, mostoperating systems store files on ahard disk. Hard disks have been the ubiquitous form ofnon-volatile storage since the early 1960s.[8] Where files contain only temporary information, they may be stored inRAM. Computer files can be also stored on other media in some cases, such asmagnetic tapes,compact discs,Digital Versatile Discs,Zip drives,USB flash drives, etc. The use ofsolid state drives is also beginning to rival the hard disk drive.

In Unix-like operating systems, many files have no associated physical storage device. Examples are/dev/null and most files under directories/dev,/proc and/sys. These are virtual files: they exist as objects within the operating system kernel.

As seen by a running user program, files are usually represented either by afile control block or by afile handle. A file control block (FCB) is an area of memory which is manipulated to establish a filename etc. and then passed to the operating system as a parameter; it was used by older IBM operating systems and early PC operating systems includingCP/M and early versions ofMS-DOS. A file handle is generally either anopaque data type or an integer; it was introduced in around 1961 by theALGOL-basedBurroughs MCP running on theBurroughs B5000 but is now ubiquitous.

File corruption

[edit]
Further information:Data corruption andData degradation
Photo of a child
OriginalJPEG file
Corrupted JPEG file, with a singlebit flipped (turned from 0 to 1, or vice versa)
While there is visible corruption on the second file, one can still make out what the original image might have looked like.

When a file is said to be corrupted, it is because its contents have been saved to the computer in such a way that they cannot be properly read, either by a human or by software. Depending on the extent of the damage, the original file can sometimes berecovered, or at least partially understood.[9] A file may be created corrupt, or it may be corrupted at a later point through overwriting.

There are many ways by which a file can become corrupted. Most commonly, the issue happens in the process ofwriting the file to adisk.[10] For example, if animage-editing program unexpectedlycrashes while saving an image, that file may be corrupted because the program could not save its entirety. The program itself might warn the user that there was an error, allowing for another attempt at saving the file.[11] Some other examples of reasons for which files become corrupted include:

File corruption is typically unintentional; however, it may be done intentionally as an act ofdeception so that a student or employee can receive an extension on their deadline. There are services that provide on demand file corruption, which essentially fill a given file with random data so that it cannot be opened or read yet still seems legitimate.[18][19]

One of the most effective countermeasures for unintentional file corruption isbacking up important files.[20] In the event of an important file becoming corrupted, the user can simply replace it with the backed up version.

Backup

[edit]
Main article:Backup

When computer files contain information that is extremely important, aback-up process is used to protect against disasters that might destroy the files. Backing up files simply means making copies of the files in a separate location so that they can be restored if something happens to the computer, or if they are deleted accidentally.

There are many ways to back up files. Most computer systems provide utility programs to assist in the back-up process, which can become very time-consuming if there are many files to safeguard. Files are often copied to removable media such as writable CDs or cartridge tapes. Copying files to another hard disk in the same computer protects against failure of one disk, but if it is necessary to protect against failure or destruction of the entire computer, then copies of the files must be made on other media that can be taken away from the computer and stored in a safe, distant location.

Thegrandfather-father-son backup method automatically makes three back-ups; the grandfather file is the oldest copy of the file and the son is the current copy.

File systems and file managers

[edit]

The way a computer organizes, names, stores and manipulates files is globally referred to as itsfile system. Most computers have at least one file system. Some computers allow the use of several different file systems. For instance, on newer MS Windows computers, the older FAT-type file systems ofMS-DOS and old versions of Windows are supported, in addition to theNTFS file system that is the normal file system for recent versions of Windows. Each system has its own advantages and disadvantages. Standard FAT allows only eight-character file names (plus a three-character extension) with no spaces, for example, whereas NTFS allows much longer names that can contain spaces. You can call a file "Payroll records" in NTFS, but in FAT you would be restricted to something likepayroll.dat (unless you were usingVFAT, a FAT extension allowing long file names).

File manager programs are utility programs that allow users to manipulate files directly. They allow you to move, create, delete and rename files and folders, although they do not actually allow you to read the contents of a file or store information in it. Every computer system provides at least one file-manager program for its native file system. For example,File Explorer (formerly Windows Explorer) is commonly used in Microsoft Windows operating systems, andNautilus is common under several distributions of Linux.

See also

[edit]

Notes

[edit]
  1. ^Can also be shown as kilobytes, megabytes, gigabytes, etc.

References

[edit]
  1. ^"Online Etymology Dictionary".Archived from the original on 2015-09-24. Retrieved2015-08-17.
  2. ^Eckert, W. J.; Thomas J. Watson Astronomical Computing Bureau, New York. (1940).Punched card methods in scientific computation. New York: The Thomas J. Watson Astronomical Computing Bureau, Columbia University.Archived from the original on 2020-06-12. Retrieved2018-04-17.
  3. ^Comrie, L. J. (1928-04-13)."On the Construction of Tables by Interpolation (Plate 6)".Monthly Notices of the Royal Astronomical Society.88 (6):506–523.Bibcode:1928MNRAS..88..506C.doi:10.1093/mnras/88.6.506.ISSN 0035-8711.
  4. ^Popular Science. Bonnier Corporation. February 1950. p. 96.Archived from the original on 2022-01-09. Retrieved2014-03-07.
  5. ^Robert S. Casey, et al.Punched Cards: Their Applications to Science and Industry. 1952.
  6. ^Martin H. Weik. Ballistic Research Laboratories Report #1115. March 1961.pp. 314–331Archived 2016-10-21 at theWayback Machine.
  7. ^fallocate(1)
  8. ^Magnetic Storage Handbook 2nd Ed., Section 2.1.1, Disk File Technology, Mee and Daniel, (c)1990,
  9. ^abcdGorski, Victoria."What Causes a Corrupt File?".Archived from the original on 2020-07-28. Retrieved2019-03-17.
  10. ^abcdWilliams, Jane (2019-01-14)."What Does It Mean When Your File Is Corrupt?".Houston Chronicle.Archived from the original on 2019-07-15. Retrieved2019-03-17.
  11. ^abGlenn, Walter (2017-12-14)."What Is a Corrupted File, and Is There a Way to Get It Back?". How-To Geek.Archived from the original on 2018-12-06. Retrieved2019-03-17.
  12. ^"What Causes Flash Memory Corruption?".SecureDataRecovery.Archived from the original on 2020-07-28. Retrieved2019-03-17.
  13. ^Hoffman, Chris (2016-09-28)."Do You Really Need to Safely Remove USB Flash Drives?". How-To Geek.Archived from the original on 2019-03-30. Retrieved2019-03-17.
  14. ^"Open a document after a file corruption error".Microsoft Office Support.Archived from the original on 2019-08-28. Retrieved2019-03-17.
  15. ^ab"What kills your Flash Drive and how you can avoid it". DataRecovery.net.Archived from the original on 2018-09-06. Retrieved2019-03-17.
  16. ^Neagoe, Robert (2018-08-14)."Fix Windows 10 File Corruption Issues". Windowsreport.com.Archived from the original on 2020-07-28. Retrieved2019-03-17.
  17. ^International Council of Electronic Commerce Consultants (2009-09-24)."Mac OS X Hacking".Ethical Hacking and Countermeasures: Linux, Macintosh and Mobile Systems.Cengage. pp. 2.6 –2.7.ISBN 978-1-4354-8364-4.Archived from the original on 2020-07-29. Retrieved2019-03-17.
  18. ^"Corrupt a file - Corrupt file online, deliver on time!".Archived from the original on 2019-03-23. Retrieved2019-03-17.
  19. ^"Corrupt My File: Get your file corrupted for you".Archived from the original on 2019-03-15. Retrieved2019-03-17.
  20. ^"What is a Corrupted File?".Intego. 2019-03-07.Archived from the original on 2020-07-28. Retrieved2019-03-17.

External links

[edit]
Types
Properties
Organisation
Operations
Linking
Management
Retrieved from "https://en.wikipedia.org/w/index.php?title=Computer_file&oldid=1297092442"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2025 Movatter.jp