[287] | 1 | /*
|
---|
| 2 | * TOPPERS/ECNL Prototyping tool
|
---|
| 3 | *
|
---|
| 4 | * Copyright (C) 2017 Cores Co., Ltd. Japan
|
---|
| 5 | *
|
---|
| 6 | * 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
|
---|
| 7 | * ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改
|
---|
| 8 | * 変・再配布(以下,利用と呼ぶ)することを無償で許諾する.
|
---|
| 9 | * (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
|
---|
| 10 | * 権表示,この利用条件および下記の無保証規定が,そのままの形でソー
|
---|
| 11 | * スコード中に含まれていること.
|
---|
| 12 | * (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使
|
---|
| 13 | * 用できる形で再配布する場合には,再配布に伴うドキュメント(利用
|
---|
| 14 | * 者マニュアルなど)に,上記の著作権表示,この利用条件および下記
|
---|
| 15 | * の無保証規定を掲載すること.
|
---|
| 16 | * (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使
|
---|
| 17 | * 用できない形で再配布する場合には,次のいずれかの条件を満たすこ
|
---|
| 18 | * と.
|
---|
| 19 | * (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著
|
---|
| 20 | * 作権表示,この利用条件および下記の無保証規定を掲載すること.
|
---|
| 21 | * (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに
|
---|
| 22 | * 報告すること.
|
---|
| 23 | * (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
|
---|
| 24 | * 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること.
|
---|
| 25 | * また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理
|
---|
| 26 | * 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを
|
---|
| 27 | * 免責すること.
|
---|
| 28 | *
|
---|
| 29 | * 本ソフトウェアは,無保証で提供されているものである.上記著作権者お
|
---|
| 30 | * よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的
|
---|
| 31 | * に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ
|
---|
| 32 | * アの利用により直接的または間接的に生じたいかなる損害に関しても,そ
|
---|
| 33 | * の責任を負わない.
|
---|
| 34 | *
|
---|
| 35 | * @(#) $Id$
|
---|
| 36 | */
|
---|
| 37 | using System;
|
---|
[270] | 38 | using Bridge;
|
---|
| 39 | using Bridge.Html5;
|
---|
| 40 |
|
---|
| 41 | [External]
|
---|
| 42 | public class FileSystem
|
---|
| 43 | {
|
---|
| 44 | /// <summary>
|
---|
| 45 | /// Converts a major and minor number into a single unique integer.
|
---|
| 46 | /// This is used as an id to represent the device.
|
---|
| 47 | /// </summary>
|
---|
| 48 | /// <param name="ma">Major number.</param>
|
---|
| 49 | /// <param name="mi">Minor number.</param>
|
---|
| 50 | internal int makedev(int ma, int mi)
|
---|
| 51 | {
|
---|
| 52 | throw new NotImplementedException();
|
---|
| 53 | }
|
---|
| 54 |
|
---|
| 55 | /// <summary>
|
---|
| 56 | /// Registers the specified device driver with a set of callbacks.
|
---|
| 57 | /// </summary>
|
---|
| 58 | /// <param name="dev">The specific device driver id, created using makedev().</param>
|
---|
| 59 | /// <param name="ops">The set of callbacks required by the device.
|
---|
| 60 | /// For an example, see the NODEFS default callbacks
|
---|
| 61 | /// https://github.com/kripken/emscripten/blob/1.29.12/src/library_nodefs.js#L213</param>
|
---|
| 62 | internal void registerDevice(int dev, object ops)
|
---|
| 63 | {
|
---|
| 64 | throw new NotImplementedException();
|
---|
| 65 | }
|
---|
| 66 |
|
---|
| 67 | /// <summary>
|
---|
| 68 | /// Sets up standard I/O devices for stdin, stdout, and stderr.
|
---|
| 69 | /// The devices are set up using the following (optional) callbacks.
|
---|
| 70 | /// If any of the callbacks throw an exception,
|
---|
| 71 | /// it will be caught and handled as if the device malfunctioned.
|
---|
| 72 | /// </summary>
|
---|
| 73 | /// <param name="input">Input callback. This will be called with
|
---|
| 74 | /// no parameters whenever the program attempts to read from stdin.
|
---|
| 75 | /// It should return an ASCII character code when data is available,
|
---|
| 76 | /// or null when it isn’t.</param>
|
---|
| 77 | /// <param name="output">Output callback. This will be called with
|
---|
| 78 | /// an ASCII character code whenever the program writes to stdout.
|
---|
| 79 | /// It may also be called with null to flush the output.</param>
|
---|
| 80 | /// <param name="error">Error callback. This is similar to output,
|
---|
| 81 | /// except it is called when data is written to stderr.</param>
|
---|
| 82 | /// <returns></returns>
|
---|
| 83 | internal object init(Delegate input, Delegate output, Delegate error)
|
---|
| 84 | {
|
---|
| 85 | throw new NotImplementedException();
|
---|
| 86 | }
|
---|
| 87 |
|
---|
| 88 | /// <summary>
|
---|
| 89 | /// Mounts the FS object specified by type to the directory
|
---|
| 90 | /// specified by mountpoint. The opts object is specific
|
---|
| 91 | /// to each file system type.
|
---|
| 92 | /// </summary>
|
---|
| 93 | /// <param name="type">The file system type: MEMFS, NODEFS, IDBFS or WORKERFS.</param>
|
---|
| 94 | /// <param name="opts">A generic settings object used by the underlying file system.</param>
|
---|
| 95 | /// <param name="mountpoint">A path to an existing local Emscripten directory
|
---|
| 96 | /// where the file system is to be mounted. It can be either an absolute path,
|
---|
| 97 | /// or something relative to the current directory.</param>
|
---|
| 98 | internal void mount(object type, object opts, string mountpoint)
|
---|
| 99 | {
|
---|
| 100 | throw new NotImplementedException();
|
---|
| 101 | }
|
---|
| 102 |
|
---|
| 103 | /// <summary>
|
---|
| 104 | /// Unmounts the specified mountpoint.
|
---|
| 105 | /// </summary>
|
---|
| 106 | /// <param name="mountpoint">The directory to unmount.</param>
|
---|
| 107 | internal void unmount(string mountpoint)
|
---|
| 108 | {
|
---|
| 109 | throw new NotImplementedException();
|
---|
| 110 | }
|
---|
| 111 |
|
---|
| 112 | /// <summary>
|
---|
| 113 | /// Responsible for iterating and synchronizing all mounted file systems
|
---|
| 114 | /// in an asynchronous fashion.
|
---|
| 115 | /// </summary>
|
---|
| 116 | /// <param name="populate">true to initialize Emscripten’s file system data
|
---|
| 117 | /// with the data from the file system’s persistent source,
|
---|
| 118 | /// and false to save Emscripten`s file system data
|
---|
| 119 | /// to the file system’s persistent source.</param>
|
---|
| 120 | /// <param name="callback">A notification callback function
|
---|
| 121 | /// that is invoked on completion of the synchronization.
|
---|
| 122 | /// If an error occurred, it will be provided as a parameter to this function.</param>
|
---|
| 123 | internal void syncfs(bool populate, Delegate callback)
|
---|
| 124 | {
|
---|
| 125 |
|
---|
| 126 | }
|
---|
| 127 |
|
---|
| 128 | /// <summary>
|
---|
| 129 | /// Creates a new directory node in the file system.
|
---|
| 130 | /// </summary>
|
---|
| 131 | /// <param name="path">The path name for the new directory node.</param>
|
---|
| 132 | /// <param name="mode">File permissions for the new node.
|
---|
| 133 | /// The default setting (in octal numeric notation) is 0777.</param>
|
---|
| 134 | internal void mkdir(string path, int mode)
|
---|
| 135 | {
|
---|
| 136 | throw new NotImplementedException();
|
---|
| 137 | }
|
---|
| 138 |
|
---|
| 139 | /// <summary>
|
---|
| 140 | /// Creates a new device node in the file system referencing
|
---|
| 141 | /// the registered device driver (FS.registerDevice()) for dev.
|
---|
| 142 | /// </summary>
|
---|
| 143 | /// <param name="path">The path name for the new device node.</param>
|
---|
| 144 | /// <param name="mode">File permissions for the new node.
|
---|
| 145 | /// The default setting (in octal numeric notation) is 0777.</param>
|
---|
| 146 | /// <param name="dev">The registered device driver.</param>
|
---|
| 147 | internal void mkdev(string path, int mode, int dev)
|
---|
| 148 | {
|
---|
| 149 | throw new NotImplementedException();
|
---|
| 150 | }
|
---|
| 151 |
|
---|
| 152 | /// <summary>
|
---|
| 153 | /// Creates a symlink node at newpath linking to oldpath.
|
---|
| 154 | /// </summary>
|
---|
| 155 | /// <param name="oldpath">The path name of the file to link to.</param>
|
---|
| 156 | /// <param name="newpath">The path to the new symlink node, that points to oldpath.</param>
|
---|
| 157 | internal void symlink(string oldpath, string newpath)
|
---|
| 158 | {
|
---|
| 159 | throw new NotImplementedException();
|
---|
| 160 | }
|
---|
| 161 |
|
---|
| 162 | internal Stat stat(string path)
|
---|
| 163 | {
|
---|
| 164 | return new Stat();
|
---|
| 165 | }
|
---|
| 166 |
|
---|
| 167 | internal File open(string path, string flag)
|
---|
| 168 | {
|
---|
| 169 | return new File();
|
---|
| 170 | }
|
---|
| 171 |
|
---|
| 172 | internal void close(File stream)
|
---|
| 173 | {
|
---|
| 174 | }
|
---|
| 175 |
|
---|
| 176 | internal void read(File stream, Uint8Array buffer, int offset, int length, int position)
|
---|
| 177 | {
|
---|
| 178 | }
|
---|
| 179 |
|
---|
| 180 | /// <summary>
|
---|
| 181 | /// Writes the entire contents of data to the file at path.
|
---|
| 182 | /// The value of opts determines whether data is treated
|
---|
| 183 | /// either as a string (encoding = utf8), or as an ArrayBufferView(encoding = binary).
|
---|
| 184 | /// </summary>
|
---|
| 185 | /// <param name="path">The file to which to write data.</param>
|
---|
| 186 | /// <param name="data">The data to write.</param>
|
---|
| 187 | /// <param name="opts">
|
---|
| 188 | /// encoding(string)
|
---|
| 189 | /// binary | utf8.The default is utf8
|
---|
| 190 | /// flags(string)
|
---|
| 191 | /// Write flags, as defined in FS.open(). The default is ‘w’.
|
---|
| 192 | /// </param>
|
---|
| 193 | internal void writeFile(string path, object data, object opts = null)
|
---|
| 194 | {
|
---|
| 195 | throw new NotImplementedException();
|
---|
| 196 | }
|
---|
| 197 |
|
---|
| 198 | /// <summary>
|
---|
| 199 | /// Preloads a file asynchronously, and uses preload plugins to prepare its content.
|
---|
| 200 | /// You should call this in preRun, run() will be delayed until all preloaded files are ready.
|
---|
| 201 | /// This is how the preload-file option works in emcc
|
---|
| 202 | /// when --use-preload-plugins has been specified (if you use this method by itself,
|
---|
| 203 | /// you will need to build the program with that option).
|
---|
| 204 | /// </summary>
|
---|
| 205 | /// <param name="parent">The parent folder, either as a path (e.g. ‘/usr/lib’) or
|
---|
| 206 | /// an object previously returned from a FS.createFolder() or FS.createPath() call.</param>
|
---|
| 207 | /// <param name="name">The name of the new file.</param>
|
---|
| 208 | /// <param name="url">In the browser, this is the URL whose contents will be returned
|
---|
| 209 | /// when the file is accessed. In a command line engine,
|
---|
| 210 | /// this will be the local (real) file system path the contents
|
---|
| 211 | /// will be loaded from. Note that writes to this file are virtual.</param>
|
---|
| 212 | /// <param name="canRead">Whether the file should have read permissions set
|
---|
| 213 | /// from the program’s point of view.</param>
|
---|
| 214 | /// <param name="canWrite">Whether the file should have write permissions set
|
---|
| 215 | /// from the program’s point of view.</param>
|
---|
| 216 | internal void createPreloadedFile(string parent, string name, string url, bool canRead, bool canWrite)
|
---|
| 217 | {
|
---|
| 218 | throw new NotImplementedException();
|
---|
| 219 | }
|
---|
| 220 |
|
---|
| 221 | internal void createFolder(string parent, string name, bool canRead, bool canWrite)
|
---|
| 222 | {
|
---|
| 223 | throw new NotImplementedException();
|
---|
| 224 | }
|
---|
| 225 | }
|
---|
| 226 |
|
---|
| 227 | [External]
|
---|
| 228 | class Stat
|
---|
| 229 | {
|
---|
| 230 | internal int size = 0;
|
---|
| 231 | }
|
---|
| 232 |
|
---|
| 233 | [External]
|
---|
| 234 | class File
|
---|
| 235 | {
|
---|
| 236 |
|
---|
| 237 | }
|
---|