[270] | 1 | using System;
|
---|
| 2 | using Bridge;
|
---|
| 3 | using Bridge.Html5;
|
---|
| 4 |
|
---|
| 5 | [External]
|
---|
| 6 | public class FileSystem
|
---|
| 7 | {
|
---|
| 8 | /// <summary>
|
---|
| 9 | /// Converts a major and minor number into a single unique integer.
|
---|
| 10 | /// This is used as an id to represent the device.
|
---|
| 11 | /// </summary>
|
---|
| 12 | /// <param name="ma">Major number.</param>
|
---|
| 13 | /// <param name="mi">Minor number.</param>
|
---|
| 14 | internal int makedev(int ma, int mi)
|
---|
| 15 | {
|
---|
| 16 | throw new NotImplementedException();
|
---|
| 17 | }
|
---|
| 18 |
|
---|
| 19 | /// <summary>
|
---|
| 20 | /// Registers the specified device driver with a set of callbacks.
|
---|
| 21 | /// </summary>
|
---|
| 22 | /// <param name="dev">The specific device driver id, created using makedev().</param>
|
---|
| 23 | /// <param name="ops">The set of callbacks required by the device.
|
---|
| 24 | /// For an example, see the NODEFS default callbacks
|
---|
| 25 | /// https://github.com/kripken/emscripten/blob/1.29.12/src/library_nodefs.js#L213</param>
|
---|
| 26 | internal void registerDevice(int dev, object ops)
|
---|
| 27 | {
|
---|
| 28 | throw new NotImplementedException();
|
---|
| 29 | }
|
---|
| 30 |
|
---|
| 31 | /// <summary>
|
---|
| 32 | /// Sets up standard I/O devices for stdin, stdout, and stderr.
|
---|
| 33 | /// The devices are set up using the following (optional) callbacks.
|
---|
| 34 | /// If any of the callbacks throw an exception,
|
---|
| 35 | /// it will be caught and handled as if the device malfunctioned.
|
---|
| 36 | /// </summary>
|
---|
| 37 | /// <param name="input">Input callback. This will be called with
|
---|
| 38 | /// no parameters whenever the program attempts to read from stdin.
|
---|
| 39 | /// It should return an ASCII character code when data is available,
|
---|
| 40 | /// or null when it isn’t.</param>
|
---|
| 41 | /// <param name="output">Output callback. This will be called with
|
---|
| 42 | /// an ASCII character code whenever the program writes to stdout.
|
---|
| 43 | /// It may also be called with null to flush the output.</param>
|
---|
| 44 | /// <param name="error">Error callback. This is similar to output,
|
---|
| 45 | /// except it is called when data is written to stderr.</param>
|
---|
| 46 | /// <returns></returns>
|
---|
| 47 | internal object init(Delegate input, Delegate output, Delegate error)
|
---|
| 48 | {
|
---|
| 49 | throw new NotImplementedException();
|
---|
| 50 | }
|
---|
| 51 |
|
---|
| 52 | /// <summary>
|
---|
| 53 | /// Mounts the FS object specified by type to the directory
|
---|
| 54 | /// specified by mountpoint. The opts object is specific
|
---|
| 55 | /// to each file system type.
|
---|
| 56 | /// </summary>
|
---|
| 57 | /// <param name="type">The file system type: MEMFS, NODEFS, IDBFS or WORKERFS.</param>
|
---|
| 58 | /// <param name="opts">A generic settings object used by the underlying file system.</param>
|
---|
| 59 | /// <param name="mountpoint">A path to an existing local Emscripten directory
|
---|
| 60 | /// where the file system is to be mounted. It can be either an absolute path,
|
---|
| 61 | /// or something relative to the current directory.</param>
|
---|
| 62 | internal void mount(object type, object opts, string mountpoint)
|
---|
| 63 | {
|
---|
| 64 | throw new NotImplementedException();
|
---|
| 65 | }
|
---|
| 66 |
|
---|
| 67 | /// <summary>
|
---|
| 68 | /// Unmounts the specified mountpoint.
|
---|
| 69 | /// </summary>
|
---|
| 70 | /// <param name="mountpoint">The directory to unmount.</param>
|
---|
| 71 | internal void unmount(string mountpoint)
|
---|
| 72 | {
|
---|
| 73 | throw new NotImplementedException();
|
---|
| 74 | }
|
---|
| 75 |
|
---|
| 76 | /// <summary>
|
---|
| 77 | /// Responsible for iterating and synchronizing all mounted file systems
|
---|
| 78 | /// in an asynchronous fashion.
|
---|
| 79 | /// </summary>
|
---|
| 80 | /// <param name="populate">true to initialize Emscripten’s file system data
|
---|
| 81 | /// with the data from the file system’s persistent source,
|
---|
| 82 | /// and false to save Emscripten`s file system data
|
---|
| 83 | /// to the file system’s persistent source.</param>
|
---|
| 84 | /// <param name="callback">A notification callback function
|
---|
| 85 | /// that is invoked on completion of the synchronization.
|
---|
| 86 | /// If an error occurred, it will be provided as a parameter to this function.</param>
|
---|
| 87 | internal void syncfs(bool populate, Delegate callback)
|
---|
| 88 | {
|
---|
| 89 |
|
---|
| 90 | }
|
---|
| 91 |
|
---|
| 92 | /// <summary>
|
---|
| 93 | /// Creates a new directory node in the file system.
|
---|
| 94 | /// </summary>
|
---|
| 95 | /// <param name="path">The path name for the new directory node.</param>
|
---|
| 96 | /// <param name="mode">File permissions for the new node.
|
---|
| 97 | /// The default setting (in octal numeric notation) is 0777.</param>
|
---|
| 98 | internal void mkdir(string path, int mode)
|
---|
| 99 | {
|
---|
| 100 | throw new NotImplementedException();
|
---|
| 101 | }
|
---|
| 102 |
|
---|
| 103 | /// <summary>
|
---|
| 104 | /// Creates a new device node in the file system referencing
|
---|
| 105 | /// the registered device driver (FS.registerDevice()) for dev.
|
---|
| 106 | /// </summary>
|
---|
| 107 | /// <param name="path">The path name for the new device node.</param>
|
---|
| 108 | /// <param name="mode">File permissions for the new node.
|
---|
| 109 | /// The default setting (in octal numeric notation) is 0777.</param>
|
---|
| 110 | /// <param name="dev">The registered device driver.</param>
|
---|
| 111 | internal void mkdev(string path, int mode, int dev)
|
---|
| 112 | {
|
---|
| 113 | throw new NotImplementedException();
|
---|
| 114 | }
|
---|
| 115 |
|
---|
| 116 | /// <summary>
|
---|
| 117 | /// Creates a symlink node at newpath linking to oldpath.
|
---|
| 118 | /// </summary>
|
---|
| 119 | /// <param name="oldpath">The path name of the file to link to.</param>
|
---|
| 120 | /// <param name="newpath">The path to the new symlink node, that points to oldpath.</param>
|
---|
| 121 | internal void symlink(string oldpath, string newpath)
|
---|
| 122 | {
|
---|
| 123 | throw new NotImplementedException();
|
---|
| 124 | }
|
---|
| 125 |
|
---|
| 126 | internal Stat stat(string path)
|
---|
| 127 | {
|
---|
| 128 | return new Stat();
|
---|
| 129 | }
|
---|
| 130 |
|
---|
| 131 | internal File open(string path, string flag)
|
---|
| 132 | {
|
---|
| 133 | return new File();
|
---|
| 134 | }
|
---|
| 135 |
|
---|
| 136 | internal void close(File stream)
|
---|
| 137 | {
|
---|
| 138 | }
|
---|
| 139 |
|
---|
| 140 | internal void read(File stream, Uint8Array buffer, int offset, int length, int position)
|
---|
| 141 | {
|
---|
| 142 | }
|
---|
| 143 |
|
---|
| 144 | /// <summary>
|
---|
| 145 | /// Writes the entire contents of data to the file at path.
|
---|
| 146 | /// The value of opts determines whether data is treated
|
---|
| 147 | /// either as a string (encoding = utf8), or as an ArrayBufferView(encoding = binary).
|
---|
| 148 | /// </summary>
|
---|
| 149 | /// <param name="path">The file to which to write data.</param>
|
---|
| 150 | /// <param name="data">The data to write.</param>
|
---|
| 151 | /// <param name="opts">
|
---|
| 152 | /// encoding(string)
|
---|
| 153 | /// binary | utf8.The default is utf8
|
---|
| 154 | /// flags(string)
|
---|
| 155 | /// Write flags, as defined in FS.open(). The default is ‘w’.
|
---|
| 156 | /// </param>
|
---|
| 157 | internal void writeFile(string path, object data, object opts = null)
|
---|
| 158 | {
|
---|
| 159 | throw new NotImplementedException();
|
---|
| 160 | }
|
---|
| 161 |
|
---|
| 162 | /// <summary>
|
---|
| 163 | /// Preloads a file asynchronously, and uses preload plugins to prepare its content.
|
---|
| 164 | /// You should call this in preRun, run() will be delayed until all preloaded files are ready.
|
---|
| 165 | /// This is how the preload-file option works in emcc
|
---|
| 166 | /// when --use-preload-plugins has been specified (if you use this method by itself,
|
---|
| 167 | /// you will need to build the program with that option).
|
---|
| 168 | /// </summary>
|
---|
| 169 | /// <param name="parent">The parent folder, either as a path (e.g. ‘/usr/lib’) or
|
---|
| 170 | /// an object previously returned from a FS.createFolder() or FS.createPath() call.</param>
|
---|
| 171 | /// <param name="name">The name of the new file.</param>
|
---|
| 172 | /// <param name="url">In the browser, this is the URL whose contents will be returned
|
---|
| 173 | /// when the file is accessed. In a command line engine,
|
---|
| 174 | /// this will be the local (real) file system path the contents
|
---|
| 175 | /// will be loaded from. Note that writes to this file are virtual.</param>
|
---|
| 176 | /// <param name="canRead">Whether the file should have read permissions set
|
---|
| 177 | /// from the program’s point of view.</param>
|
---|
| 178 | /// <param name="canWrite">Whether the file should have write permissions set
|
---|
| 179 | /// from the program’s point of view.</param>
|
---|
| 180 | internal void createPreloadedFile(string parent, string name, string url, bool canRead, bool canWrite)
|
---|
| 181 | {
|
---|
| 182 | throw new NotImplementedException();
|
---|
| 183 | }
|
---|
| 184 |
|
---|
| 185 | internal void createFolder(string parent, string name, bool canRead, bool canWrite)
|
---|
| 186 | {
|
---|
| 187 | throw new NotImplementedException();
|
---|
| 188 | }
|
---|
| 189 | }
|
---|
| 190 |
|
---|
| 191 | [External]
|
---|
| 192 | class Stat
|
---|
| 193 | {
|
---|
| 194 | internal int size = 0;
|
---|
| 195 | }
|
---|
| 196 |
|
---|
| 197 | [External]
|
---|
| 198 | class File
|
---|
| 199 | {
|
---|
| 200 |
|
---|
| 201 | }
|
---|