📄 filetypes.txt
字号:
z 1998-08-09 Emil Brink gentoo FileTypesINTRODUCTIONThis document describes the gentoo filetyping architecture, i.e. themeans by which gentoo clasfsifies each file it shows as belonging toexactly one previously defined file type. This classification is thenused to determine how gentoo is to deal with that file; it helpsspecifying display colors and/or pixmaps, action commands, and so on. In this document, the word "file" is used in a very generalsense. A file is anything that can be found in a disk directory. Sincegentoo runs on Linux (and perhaps other Unices?), this means that a filecan be a directory, a plain file, a (soft) link, a (block or character)device, a socket, or a FIFO. At least I _think_ that's all...THE FILETYPEA filetype is, technically, a named tuple of identification methods.These methods can be applied to a dirpane line to determine if the diskentry described by the line belongs to the type or not. A filetype can use anything from one to four available "levels"of identification methods in order to determine if a given line has thetype. These levels are:1) inode typeThis is the simplest, fastest, most low-level check. The inodetype tells if the line is a directory, a soft link, plain file,device, et cetera. A filetype MUST ALWAYS specify exactly ONEinode type.2) ProtectionUsing the protection matching rule, you can require files to have acertain combination of protection bits. You can currently only specifywhich bits must be set, not which must NOT be set (i.e. clear). Thismeans that you can find all files that are writable, but not all filesthat are NOT writable... I don't know how important this really is,but it feels kind'a incomplete right now.3) Suffix MatchThe suffix match is used to require that the file name ends in a certainstring. This is very useful to find normal extensions, since a typicalextension is just a suffix with a dot first. For example, you could usethe suffix match to require that candidate lines have names ending in".gif". This check is highly specialized and therefore fairly quick. Since the suffix checker is meant to be lean, mean and quick,it only allows one suffix rather than a list. If you need to checkagainst several suffixes (suffici? suffixen?), you'll need to move tothe next leve, the regular expression matcher.4) Name Regular Expression MatchIf the names you're trying to find have some similarity more complexthan just a plain suffix, maybe you can use this level. It lets youspecify a full regular expression (using the V8 syntax found elsewherein gentoo) against which file names are checked. For example, if youwhere looking for MOD files on an Amiga partition, you might specifya name RE of "^mod\..*". Or you could identify tar+gzipped files with"(\.tar\.gz$)|(\.tgz$)".5) 'file' Regular Expression MatchWhen none of the previous levels suffice, you can resort to the finalsecret weapon; the 'file' regular expression matcher. This runs theUNIX standard utility 'file' on the dirpane line in question, and thentries to match the regular expression you supplied against file'soutput. Using this level, you can perform virtually any kind of fileidentification necessary, since you can add things to the "magic" file/etc/magic used by file. As an example, you can identify executable files in the ELFformat (standard on modern Linuxes) by specifying a 'file' matching REof e.g. "ELF 32-bit (L|M)SB executable.*", or just plain "ELF.*".Note that the RE you specify is only checked against the part of file'soutput that is after the first colon. Please remember that using 'file' RE matching in your filetyping SEVERLY degrades gentoo's performance. Beware. I'm waiting fora new release of the 'file' package that incorporates a tiny fix whichwill allow gentoo to use it with much greater efficiency...FILETYPING STRUCTUREGentoo maintains a set (e.g. a list) of filetype definitions; there isno hierarchy or any other complex structure involved. The definitionsare applied one by one in search for a match. As soon as any a match isfound, the search is terminated and the line as considered to have thetype that matched. If no type matched, the built-in always present type "Unknown"is assigned to the line, in order to guarantee that all dirpane linesalways have exactly one type assigned to them. The ordering of the filetypes internally influences the speedof the matching process; this is something I will investigate once thefiletyping has been more fully implemented and is somewhat stable.STYLESA filetype is just a way of specifying how to identify files that havethings in common. Once the files have been partitioned into groups bytheir file types, it would be nice to take advantage of this groupingwhen working with the files. This is done through the use of styles. A style contains information that gentoo uses when renderingthe dirpane; colors and pixmaps for example. It also holds data usedwhen you manipulate the file (double-clicking it, or trying to view itwith the built-in View command). Styles, unlike filetypes, form a tree structure. There is asingle, always-present, "root" style. Other styles then appear as eitherinternal or leaf nodes in the tree based in the root style.STYLE PROPERTIESThe following properties can be specified in a style:DISPLAY Unselected Background Color Foreground Color Pixmap Icon Selected Background Color Foreground Color Pixmap IconACTION Double-click View Edit Print PlayPROPERTY INHERITANCEThe reason why the styles are arranged into a tree structure is tofacilitate inheritance of properties. For each style (except theroot) you specify which properties are to be changed from the onesof the parent style. Those that are not changed are then taken fromthe parent, recursively. The root style always specifies all itsproperties. If you're into C++ and object-oriented programming in general,this should be right up your alley.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -