1

Maybe it looks like a weird question, but what term should be attributed inside the code for files that are not folders to differentiate them from folders?

If I need write 2 functions isFolder() and isFile() 2nd one has a misleading name because folders are files too

closed as primarily opinion-based by gnat, GlenH7, user40980, Dan Pichelman, amon Jan 30 '16 at 23:11

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    has a misleading name are you sure? Most libraries in any language have separate is_directory/is_file functions and they behave as expected (i.e. is_file returns false for directories) – stijn Jan 27 '16 at 8:56
  • On Unix & POSIX, folders don't exist. But directories are indeed files. – Basile Starynkevitch Jan 27 '16 at 9:07
  • Note that if you're targeting Windows, "isFolder" may be a technically incorrect name. Under Windows terminology, "folder" is a user interface object that may or may not relate to a directory, while "directory" is specifically a structure on a disk or similar media. See blogs.msdn.microsoft.com/oldnewthing/20110216-00/?p=11473 for more info. – Jules Feb 2 '16 at 20:43
5

It really depends upon the file system and the operating system.

In POSIX and Unix, a file can be a directory, a plain file, a block device, a character device, a FIFO, a socket, a symbolic link, ... See POSIX stat & Linux stat(2), notice that file can have different types.

So if you want to speak of a file whose type is plain and which is a sequence of bytes, you say that is is a plain file.

If you want any file which is not a directory you could speak of a "non-directory" file (or maybe non-directory inode); it could be a plain file, a socket, a fifo, a symlink, etc...

Notice that POSIX and Linux don't know about folders (except on the desktop). They speak of directories.

Notice also that files are quite different on Windows, on MacOSX, on Linux, on POSIX....

Some experimental OSes don't even have files. They are persisting data in some other way. Historically, the very first editions of MS-DOS (or of MVS) did not had any directories (or folders).

6

This depends heavily on the filesystem and the operating system. For example, on Unix, there are no folders at all:Unix Filesystem Objects Hierarchy

Windows has completely different terminology. Classic MacOS had a different terminology, which, in OSX, is now mixing with Unix terminology.

Not the answer you're looking for? Browse other questions tagged or ask your own question.