The * nix system has a command called "file" that can tell you the basic file type. Say if you rename the binary executable name to foo.txt or rename the mp3 file to .txt, the system will always tell you the real file type. But on Windows, there are no such functions, if you rename the executable file to .txt, you cannot execute it. Can someone explain to me how this is done on a * nix system, and how can I find the real file type using C ++, especially on Windows, where I cannot use std :: system ("file blah")?
The file utility uses the libmagic library. It recognizes the "special" filetype fields in the file.Of course, you can program some formats yourself, but sometimes it takes a lot of work. For instance. when you try to distinguish between different MP4 formats.
The developers of this library have done quite a bit of work. Therefore, he advises using their results if you want to get the results of the gods, talking about what format you are dealing with (this is a big area, in fact, and knowing what type of format you work with, better rely on them, and then to your code)
- http://www.darwinsys.com/file/, . -4.26 → magic → Magdir
4.26 Windows ftp://ftp.astron.com/pub/file/
, , . , . , , , , .
UNIX file . , /usr/share/file/magic /etc/magic/, recogized file. () .
UNIX , Windows, Linux .
, Windows , . (,.txt) . , . The Old New Thing - Notepad, ...
, . , .
100% , , , . , , . , .
Unix/Linux . "" , , , - , , .
, "" Windows; - . Cygwin Windows "", .
.txt "" . - , Windows , ( , ), Unix/Linux , , . chmod a-x Linux, , .exe Windows.
.txt
chmod a-x
.exe
Source: https://habr.com/ru/post/1548435/More articles:Why is runXXX not part of the MonadTrans definition? - haskellCan I show a custom local notification view or a custom alert when the application is in the background? - iosОбрезка изображения с помощью JS-плагинаIOS static library compilation error - table of contents empty - iosDictionary for string - smalltalkImpossible to reorganize methods with underscore as parameter in lambda? - javaРабота с двумя различными базовыми командами - AFHTTPSessionManager - objective-cCall javascript function from select onChange - javascriptMagic numbers in formulas - javaHow to import a tab delimited text file using Import-CSV when the file does not have a header line? - powershellAll Articles