Prokee Module: file

From prokee
Revision as of 23:15, 6 May 2019 by Andy (talk | contribs)
Jump to navigation Jump to search

The module file provides platform independent functions for file access.

File Access Modes

The following file access modes can be used:

Mode Direction Info
r input Opens a existing file for input. Fails, if the file does not exist.
r+ input and output Opens a existing file for input and output. Fails, if the file does not exist.
w output Opens a file for output. The file will be created, if it does not jet exist. The contents of an existing file will be discarded.
w+ input and output Opens a file for input and output. The file will be created, if it does not jet exist. The contents of an existing file will be discarded.
a output Opens a file for output. The file will be created, if it does not jet exist. The output will be appended on the end of the file.
a+ input and output Opens a file for input and output. The file will be created, if it does not jet exist. The output will be appended on the end of the file.
rt r+t rt+ wt w+t wt+ at a+t at+ - Adding a t, specifies text-mode. This is the default mode, so adding a t has no effect. This mode is system specific and should only be used for text files. Text-mode is useful, if files are shared between different applications on the same operating system.
rb r+b rb+ wb w+b wb+ ab a+b ab+ - When adding a b, the file will be opened in binary-mode. When using this mode, every byte is read (or written) as it is indeed stored in the file. This mode should be used when files are shared between different operating systems.

Implementations