Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

definition of filename?

After years of programming it's still some of the simple things that keep tripping me up.

Is there a commonly agreed definition of filename ?

Even the wikipedia article confuses the two interpretations.

It starts by defining it as 'a special kind of string used to uniquely identify a file stored on the file system of a computer'. That seems clear enough, and suggests that a filename is a fully qualified filename, specifying the complete path to the file.

However, it then goes on to:

  • talk about basename and extension (so basename would contain an absolute path ?)
  • says that the length of a filename in DOS is limited to 8.3
  • says that a filename without a path part is assumed to be a file in the current working directory (so the filename does not uniquely identify a file)

So, simple questions:

  • what is a correct definition of 'filename' (include references)
  • how should I unambiguously name variables for:
    • a path to a file (which can be absolute/full or relative)
    • a path to a resource that can be a file/directory/socket
like image 217
Thomas Vander Stichele Avatar asked Nov 11 '08 12:11

Thomas Vander Stichele


People also ask

How do you define file names?

an identifying name given to an electronically stored computer file, conforming to limitations imposed by the operating system, as in length or restricted choice of characters.

What is a file short definition?

A file is an object on a computer that stores data, information, settings, or commands used with a computer program. On a computer there are three types of files, application files, data files, and system files.

What are the parts of filename?

Windows file names have two parts; the file's name, then a period followed by the extension (suffix). The extension is a three- or four-letter abbreviation that signifies the file type. For example, in letter. docx the filename is letter and the extension is docx.


1 Answers

No references, just vernacular from experience. When I'm being specific I tend to use:

path or filespec (or file specification): all of the characters needed to identify a file on a filesystem. The path may be absolute (starting from the root, or topmost, directory) or relative (starting from the currently active directory).

filename: the characters needed to identify a file within the current directory.

extension: characters at the end of the filename that typically identify the type of the file. By convention, the extension usually starts with a dot ("."), and a filename may contain more than one extension.

basename: the filename up to (but not including) the dot that begins the first extension.

like image 68
Adam Liss Avatar answered Oct 08 '22 07:10

Adam Liss