public FileStream(string path, FileMode fileMode, FileAccess fileAccess, FileInfo fileInfo) { if (fileInfo == null) fileInfo = new FileInfo(path); _name = fileInfo.GetCanonicalPath(); if ((fileAccess != FileAccess.Read) && (fileAccess != FileAccess.ReadWrite)) throw new Exception("IllegalArgumentException: fileAccess"); _isWriteable = (fileAccess == FileAccess.ReadWrite); if (fileInfo.Exists()) { try { _data = WindowEx.Atob(LocalStorage.GetItem(_name)); _length = _data.Length; } catch (Exception e) { throw (e.Message.StartsWith("IOException") ? new Exception("FileNotFoundException:" + e) : e); } } else if (_isWriteable) { _data = ""; _isDirty = true; try { Flush(); } catch (Exception e) { throw (e.Message.StartsWith("IOException") ? new Exception("FileNotFoundException:" + e) : e); } } else throw new Exception("FileNotFoundException:" + _name); }
public FileInfo(string fileName, FileInfo parent) { while (fileName.EndsWith(Separator) && (fileName.Length > 0)) fileName = fileName.Substring(0, fileName.Length - 1); int cut = fileName.LastIndexOf(SeparatorChar); if (cut == -1) _name = fileName; else if (cut == 0) { _name = fileName.Substring(cut, fileName.Length); _parent = (_name == "" ? null : Root); } else { _name = fileName.Substring(cut + 1, fileName.Length); _parent = new FileInfo(fileName.Substring(0, cut)); } }