Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Temporary file

From Wikipedia, the free encyclopedia
Computer file type
icon
This articleneeds additional citations forverification. Please helpimprove this article byadding citations to reliable sources. Unsourced material may be challenged and removed.
Find sources: "Temporary file" – news ·newspapers ·books ·scholar ·JSTOR
(January 2021) (Learn how and when to remove this message)

Atemporary file is a file created to store information temporarily, either for a program's intermediate use or for transfer to a permanent file when complete.[1] It may be created bycomputer programs for a variety of purposes, such as when a program cannot allocate enough memory for its tasks, when the program is working on data bigger than the architecture'saddress space, or as a primitive form ofinter-process communication.

Auxiliary memory

[edit]

Modernoperating systems employvirtual memory, however programs that use large amounts of data (e.g.video) may need to create temporary file(s).

Inter-process communication

[edit]

Most operating systems offer primitives such aspipes,sockets orshared memory to pass data among programs, but often the simplest way (especially for programs that follow theUnix philosophy) is to write data into a temporary file and inform the receiving program of the location of the temporary file.

Creation

[edit]

Operating systems and programming languages typically provide functions for obtaining unique temporary file names.

OnPOSIX systems, temporary files can be safely created with themkstemp ortmpfile library functions. Some systems provide the formerPOSIX (now removed)mktemp(1) program. These files are typically located in the standard temporary directory,/tmp on Unix machines or%TEMP% (which is log-in specific) on Windows machines.

A temporary file created withtmpfile is deleted automatically when the program exits or the file is closed. To generate a temporary file name that will survive past the lifespan of the creating program,tmpnam (POSIX) orGetTempFileName(...) (Windows) can be used.

PHP have thetmpfile function.[2]

Python have thetempfile module.[3]

Rust have the third-party crate tempfile.[4]

.NET have thePath.GetTempFileName method.[5]

Issues

[edit]

Some programs create temporary files and then leave them behind - they do not delete them. This can happen because the programcrashed or the developer of the program simply forgot to add the code needed to delete the temporary files after the program is done with them. The temporary files left behind can accumulate over time and consume a lot of disk space.

Temporary files may be deleted manually. Operating systems may clear out the temporary directory on a reboot, and they may have "cleaner" scripts that remove files if they have not been accessed in a certain amount of time. Also, memory-based filesystems, such astmpfs, inherently do not preserve files across a reboot.

See also

[edit]

References

[edit]
  1. ^"Windows Temporary Files".Microsoft Support. 7 July 2005. Archived fromthe original on 20 April 2010. Retrieved20 October 2019.
  2. ^"PHP: tmpfile - Manual".www.php.net. Retrieved6 May 2025.
  3. ^"tempfile — Generate temporary files and directories".Python documentation. Retrieved6 May 2025.
  4. ^"crates.io: Rust Package Registry".crates.io. Retrieved6 May 2025.
  5. ^"Path.GetTempFileName Method (System.IO)".learn.microsoft.com. Retrieved6 May 2025.
Types
Properties
Organisation
Operations
Linking
Management
Retrieved from "https://en.wikipedia.org/w/index.php?title=Temporary_file&oldid=1289151463"
Category:
Hidden categories:

[8]ページ先頭

©2009-2026 Movatter.jp