Marmos
v juptune
v asn1
v lang
v ast
v Classes
v Enums
v ir
v parser
v Enums
v Structs
v core
v crypto
v keyexchange
v memory
v data
v alphabet
v buffer
v json
v builder
v parser
v Enums
v Structs
v serialise
v Structs
v Templates
v pem
v Enums
v Structs

Structs PosixFile

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
module juptune.event.io;

struct PosixFile
{
    /++ ALIASES ++/
    
    ///
    alias __xdtor = __MARMOS_BUG__;
    ///
    alias __xpostblit = __MARMOS_BUG__;
    
    /++ FUNCTIONS ++/
    
    /// Helper function around .open for when you want to create a new file (the file must not exist already). 
    static Result createNew(const char[] path, PosixFile file, PosixFile.PermissionFlags permissions = cast(PermissionFlags)504, PosixFile.ResolveFlags resolveFlags = ResolveFlags.asNormal, PosixDirectory* cwd = null, bool pathIsNullTerminated = false);
    /// Helper function around .open for when you want to create a new file if it doesn't exist, or truncate it if it already exists. 
    static Result createOrTruncate(const char[] path, PosixFile file, PosixFile.PermissionFlags permissions = cast(PermissionFlags)504, PosixFile.ResolveFlags resolveFlags = ResolveFlags.asNormal, PosixDirectory* cwd = null, bool pathIsNullTerminated = false);
    ///
    PosixFile opAssign(PosixFile p);
    /// Opens/creates a file at the given path, using the provided flags & modes to determine the exact behaviour of the opened file. 
    static Result open(const char[] path, PosixFile.AccessMode accessMode, PosixFile.CreateMode createMode, PosixFile.Flags flags, PosixFile.ResolveFlags resolveFlags, PosixFile.PermissionFlags permissions, PosixDirectory* cwd, PosixFile file, bool pathIsNullTerminated = false);
    /// Helper function around .open for when you want to open a prexisting file for reading. 
    static Result openForReading(const char[] path, PosixFile file, PosixFile.ResolveFlags resolveFlags = ResolveFlags.asNormal, PosixDirectory* cwd = null, bool pathIsNullTerminated = false);
    
    /++ ENUMS ++/
    
    /// Determines whether the file can be written to and/or read from. 
    enum AccessMode : int
    {
        ///
        FAILSAFE = -1, 
        /// The file can only be read from. 
        readOnly = 0, 
        /// The file can only be written to. 
        writeOnly = 1, 
        /// The file can be both written to and read from. 
        readWrite = 2
    }
    /// Determines how to deal with files that don't/already exist. 
    enum CreateMode : int
    {
        /// Don't create a new file. If the file doesn't exist then you'll run into an error result. 
        dontCreate = 0, 
        /// Always attempt to create a new file. If the file already exists, then you'll run into an error result. 
        create = 192, 
        /// Always attempt to create a new file. If the file already exists then it'll be truncated. 
        truncate = 576
    }
    /// Additional flags related to opening the file. This is a bit mask that can be ORed together. 
    enum Flags : int
    {
        ///
        none = 0, 
        /// Attempt to bypass any kernal-level caching and data duplication. 
        direct = 16384, 
        /// Writes will not return until all of the data & metadata required for the file to still function, have been fully committed to disk. 
        dsync = 4096, 
        /// The file access timestamp won't be updated. 
        noAccessTime = 262144, 
        /// If the last segment of the path is a symlink, you'll run into an error result instead of opening the file. 
        noFollowTrailingSymlink = 131072
    }
    ///
    enum PermissionFlags : int
    {
        ///
        none = 0, 
        ///
        ownerRead = 256, 
        ///
        ownerWrite = 128, 
        ///
        ownerExecute = 64, 
        ///
        groupRead = 32, 
        ///
        groupWrite = 16, 
        ///
        groupExecute = 8, 
        ///
        otherRead = 4, 
        ///
        otherWrite = 2, 
        ///
        otherExecute = 1, 
        ///
        ownerAll = 448, 
        ///
        groupAll = 56
    }
    /// Flags related to changing the behaviour for how file paths are resolved. This is a bit mask that can be ORed together. 
    enum ResolveFlags : int
    {
        /// No changes. They work as you'd expect. 
        asNormal = 0, 
        /// The path to the file being opened MUST belong to the same mounting point as the current working directory. 
        mustBeOnSameMountAsCwd = 1, 
        /// "Magic links" (google it) will generate an error result upon being opened. 
        noMagicLinks = 2, 
        /// The path to the file being opened MUST NOT contain a symlink at any point in its path. 
        noSymlinksAtAnyPoint = 4, 
        /// The path MUST NOT contain a starting "/", and MUST NOT contain any usage of things like "../". This guarentees that the file being opened, is directly under the current working directory. (TODO: Would be really nice to detach this functionality from the CWD). 
        mustBeBeneathCwd = 8, 
        /// The current working directory is treated as a fake root, so "/" resolves to the CWD, and "../" cannot break out of the CWD. 
        cwdIsFakeRoot = 16
    }
    
    /++ VARIABLES ++/
    
    ///
    GenericIoDriver!(FileDescriptorReadWriteType.writeAndRead) _driver;
}

Documentation

A Fileimplementation that's probably not actually POSIX compatible.

As with all IO Driver implementations, this struct inherits GenericIoDriverfor common IO functions.

See_Also

GenericIoDriver

Aliases

Name Description
__xdtor
__xpostblit

Enums

Name Description
AccessMode

Determines whether the file can be written to and/or read from.

CreateMode

Determines how to deal with files that don't/already exist.

Flags

Additional flags related to opening the file. This is a bit mask that can be ORed together.

PermissionFlags
ResolveFlags

Flags related to changing the behaviour for how file paths are resolved. This is a bit mask that can be ORed together.

Functions

Name Description
createNew

Helper function around .openfor when you want to create a new file (the file must not exist already).

createOrTruncate

Helper function around .openfor when you want to create a new file if it doesn't exist, or truncate it if it already exists.

opAssign
open

Opens/creates a file at the given path, using the provided flags & modes to determine the exact behaviour of the opened file.

openForReading

Helper function around .openfor when you want to open a prexisting file for reading.

Variables

Name Description
_driver