Defining a file name?

After many years of programming, these are still some of the simple things that prevent me.

Is there a generally accepted definition for a file name?

Even a Wikipedia article mixes two interpretations.

It begins by defining it as "a special type of string used to uniquely identify a file stored in the computer's file system." This seems clear enough and assumes that the file name is the full file name indicating the full path to the file.

However, he then proceeds to the following:

  • talk about basename and extension (so will basename contain an absolute path?)
  • says DOS file name length is limited to 8.3
  • says that a file name without a part of the path is considered a file in the current working directory (therefore, the file name does not uniquely identify the file).

So simple questions:

  • What is the correct definition of "file name" (including links)
  • How to unambiguously name variables for:
    • file path (which can be absolute / full or relative)
    • path to the resource, which may be a file / directory / socket
+3
source share
4 answers

No links, just from best practices. When I am defined, I tend to use:

path filespec ( ): , . ( ) ( ).

filename: , .

extension: , . ( "." ), .

basename: ( ) , .

+6

ยท
(fฤซl'nฤm ') . , , , .

@Dictionary.com

, ( , ). . , , . , . ... ( , )

, .., . unix? dos/windows?

0

, . DOS (Disk Operating System). 8 , , , . , , , . . .

, . . . .

Finally, in DOS, you can specify the name of the drive. Usually one letter followed by: and a slash (in some systems, two slashes). Adding a disk to a path made it an absolute path instead of a relative one.

Today, most of us use long file names that do not match the old three-character character. However, many file systems retain the name and use the long name simply as a pointer to the old style identifier.

0
source

Source: https://habr.com/ru/post/1699410/


All Articles