Tag Info

New answers tagged

2

Make the mime-info file $ vi ~/.local/share/mime/packages/x-r-noweb.xml $ cat ~/.local/share/mime/packages/x-r-noweb.xml <?xml version="1.0" encoding="UTF-8"?> <mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info"> <mime-type type="text/x-r-noweb"> <comment>R noweb</comment> <glob ...


0

I would argue that "file type" is not even a meaningful concept under Unix; In good old days of mainframe commputers their OS's supported several file types including sequential and index-sequential. Modern operating systems (Un*x and arguably Windows) reduce the set of the file types to a minimum (including executable, shared object). It may ...


4

The system doesn't know whether a file is binary or text. In all (AFAIK) Unix-type operating systems, fopen(path, "rb") is exactly the same as fopen(path "r") - the b has no effect. It's accepted because standard C needs to be portable to some other OSes that do make such a distinction.


17

Often, it doesn't care. You just pass it to a program and either it interprets it or it doesn't. It may not be useful to open a .jpg in a text editor, but you're not prevented from doing this. The extension, like the rest of the filename, is for the organisational convenience of humans. It may also be possible to construct files that can be validly ...


68

The file utillity determines the filetype over 3 ways: First the filesystem tests: Within those tests one of the stat family system calls is invoked on the file. This returns the different unix file types: regular file, directory, link, character device, block device, named pipe or a socket. Depending on that, the magic tests are made. The magic tests are ...


7

The first thing to check is the hard-coded file type that is recognized by the kernel. These are the file types such as directory, character-special file, block-special file, pipe-special file, socket, and symbolic link. This information comes from the inode of the file. If the file is a plain file, the next set of information comes from the first 256 ...


4

The file command applies some heuristics from inspecting (parts of) the file and making a qualified guess. Beyond that there are some special cases where additional information can be obtained; like the #! at the beginning of a text file, a BoM (byte order mark), or specific header bytes of executable file formats. The #! and binary marks in executables are ...


12

That information is commonly found in the header of the file. The file command analyzes the target and tells you information about the file. A lot of information is often derived from file headers which are often times the first few bytes of a file (see below). Headers are used by the system to figure out how to handle files. #!/bin/bash at the beginning ...



Top 50 recent answers are included