Every time a stream is written, I/O-related APIs should be taken into consideration. I don't think so, but I can't remember... I hope this is the last time.
File classIn my image, I have been using file to create files... as an object-oriented program. I think file represents a file, and there is a filepath and other creatures that represent the file path.
1. File and filepath
After reading the API, I will know that I am wrong, but why? Is it wrong for me? When you are confused, Shangdu Niang (Java file) saw the following chestnuts in the first article:
John, you tease me. Uncle Lai knows that the suffix is only for people. The program depends on Protocol/resolution to determine the biological race to read. For example:
This is an image (at least the uploading of the blog is not determined by the suffix). This product is a shortcut. This product is a PDF file.
Maybe at this time you will be the same as uncle, second understanding, a simple test
In this case, we can assume that the operating system itself cannot distinguish files from each other on the path. The file class and the filepath class are difficult or there is no need to distinguish them, A path can represent both file and filepath --
2. Create a file and an API
At the time of creation, I understood it again in seconds. In the constructor, they differentiated file + filepath or the relative path + other paths (that is, this means), with only three interesting points.
1. The parent path name string and child provided by file are very nice. They will be shocked by the next use. You need to know that they are still implemented by new file (parent + path ).
2. The file is constructed using the parent path name string and the child. What is the getparent () of this file? Try it. Simple names are repeated. There is no ambiguity, just like others.
3. isabsolute is very interesting. The judgment method is quite unique. Other similar things can be used to abuse food.
NewFile ("F:"). isabsolute ():FalseNewFile ("F: \"). isabsolute ():True
3. Special characters
When I created a file in window, uncle was reminded many times that special characters cannot be used as file names... but through the program, maybe we can. Isn't reflection similar to this? (Damage encapsulation) and double quotation marks, there should be no ambiguity in the existence of the escape character, but if I fail, you don't have to worry about bypassing the judgment or anything, and you don't want to create it directly ....
First, let's assume that the visual operating system still needs to be executed by command. Maybe the special characters are basically determined when several files are created through cmd.
1. \: The Path separator... is not an escape character. If it can be transferred, I think it will be able to add special characters.
2./: Same as above... the legendary Fault Tolerance statement
3 .*? : Wildcard, which can be used for search in the upper-right corner of the window.
4. <> |: An operator that can start to redirect input and output data streams... uncle did not do anything in a day, just play this on CMD, And I feel my IQ has been suppressed ....
5? I will understand it later. As for Linux, you can understand it)
6. ": the sequelae of Space naming are allowed. In other words, the space and the special server above can both block/change the command, but when space is not allowed...
These should be regarded as the analysis of the operating system. Maybe an operating system will be able to completely ignore these advantages.