filer/dist/filer.map

1 line
408 KiB
Plaintext

{"version":3,"sources":["..\\lib\\nodash.js","..\\node_modules\\es6-promisify\\dist\\promisify.js","path.js","shared.js","constants.js","..\\node_modules\\base64-js\\index.js","..\\node_modules\\ieee754\\index.js","..\\node_modules\\isarray\\index.js","..\\node_modules\\buffer\\index.js","buffer.js","providers\\indexeddb.js","errors.js","..\\node_modules\\base64-arraybuffer\\lib\\base64-arraybuffer.js","providers\\websql.js","..\\node_modules\\process\\browser.js","..\\lib\\async.js","providers\\memory.js","providers\\index.js","shell\\environment.js","..\\node_modules\\path-browserify\\index.js","..\\node_modules\\concat-map\\index.js","..\\node_modules\\balanced-match\\index.js","..\\node_modules\\brace-expansion\\index.js","..\\node_modules\\minimatch\\minimatch.js","shell\\shell.js","..\\lib\\eventemitter.js","..\\lib\\intercom.js","fs-watcher.js","encoding.js","directory-entry.js","open-file-description.js","super-node.js","node.js","stats.js","filesystem\\implementation.js","filesystem\\interface.js","index.js"],"names":["ArrayProto","Array","prototype","nativeForEach","forEach","nativeIndexOf","indexOf","nativeSome","some","ObjProto","Object","hasOwnProperty","nativeKeys","keys","breaker","has","obj","key","call","TypeError","push","size","length","identity","value","each","iterator","context","i","any","result","index","list","contains","target","Wrapped","nodash","isArray","module","exports","normalizeArray","parts","allowAboveRoot","up","last","splice","unshift","splitPathRe","splitPath","filename","exec","resolve","resolvedPath","resolvedAbsolute","arguments","path","charAt","split","filter","p","join","normalize","isAbsolute","paths","slice","relative","from","to","substr","trim","arr","start","end","fromParts","toParts","Math","min","samePartsLength","outputParts","concat","dirname","root","dir","basename","ext","f","extname","isNull","addTrailing","replace","removeTrailing","sep","delimiter","guid","c","r","random","v","toString","toUpperCase","nop","u8toArray","u8","array","len","O_READ","O_WRITE","O_CREATE","O_EXCLUSIVE","O_TRUNCATE","O_APPEND","XATTR_CREATE","XATTR_REPLACE","FILE_SYSTEM_NAME","FILE_STORE_NAME","IDB_RO","IDB_RW","WSQL_VERSION","WSQL_SIZE","WSQL_DESC","NODE_TYPE_FILE","NODE_TYPE_DIRECTORY","NODE_TYPE_SYMBOLIC_LINK","NODE_TYPE_META","S_IFREG","S_IFDIR","S_IFLNK","DEFAULT_DIR_PERMISSIONS","DEFAULT_FILE_PERMISSIONS","FULL_READ_WRITE_EXEC_PERMISSIONS","READ_WRITE_PERMISSIONS","SYMLOOP_MAX","BINARY_MIME_TYPE","JSON_MIME_TYPE","ROOT_DIRECTORY_NAME","FS_FORMAT","FS_NOCTIME","FS_NOMTIME","FS_NODUPEIDCHECK","O_FLAGS","FS_READY","FS_PENDING","FS_ERROR","SUPER_NODE_ID","STDIN","STDOUT","STDERR","FIRST_DESCRIPTOR","ENVIRONMENT","TMP","PATH","fsConstants","O_RDONLY","O_WRONLY","O_RDWR","S_IFMT","S_IFCHR","S_IFBLK","S_IFIFO","S_IFSOCK","O_CREAT","O_EXCL","O_NOCTTY","O_TRUNC","O_DIRECTORY","O_NOFOLLOW","O_SYNC","O_DSYNC","O_SYMLINK","O_NONBLOCK","S_IRWXU","S_IRUSR","S_IWUSR","S_IXUSR","S_IRWXG","S_IRGRP","S_IWGRP","S_IXGRP","S_IRWXO","S_IROTH","S_IWOTH","S_IXOTH","F_OK","R_OK","W_OK","X_OK","UV_FS_COPYFILE_EXCL","COPYFILE_EXCL","FilerBuffer","subject","encoding","nonZero","ArrayBuffer","Uint8Array","Buffer","create","constructor","require","indexedDB","global","mozIndexedDB","webkitIndexedDB","msIndexedDB","IndexedDBContext","db","mode","_getObjectStore","objectStore","transaction","clear","callback","request","onsuccess","onerror","event","preventDefault","error","err","_get","get","getObject","getBuffer","arrayBuffer","_put","put","putObject","putBuffer","uint8BackedBuffer","buf","buffer","delete","IndexedDB","name","isSupported","open","that","openRequest","onupgradeneeded","objectStoreNames","deleteObjectStore","createObjectStore","getReadOnlyContext","getReadWriteContext","errors","e","errno","errName","defaultMessage","FilerError","msg","Error","code","message","stack","pathInfo","chars","lookup","charCodeAt","encode","arraybuffer","bytes","base64","substring","decode","bufferLength","encoded1","encoded2","encoded3","encoded4","Errors","base64ArrayBuffer","WebSQLContext","isReadOnly","getTransaction","onError","onSuccess","executeSql","rows","item","data","JSON","parse","json","stringify","WebSQL","openDatabase","EINVAL","createIndex","process","cachedSetTimeout","cachedClearTimeout","defaultSetTimout","defaultClearTimeout","setTimeout","clearTimeout","runTimeout","fun","runClearTimeout","marker","queue","draining","currentQueue","queueIndex","cleanUpNextTick","drainQueue","timeout","run","nextTick","args","Item","apply","title","browser","env","argv","version","versions","noop","on","addListener","once","off","removeListener","removeAllListeners","emit","prependListener","prependOnceListener","listeners","binding","cwd","chdir","umask","async","setImmediate","fn","eachSeries","completed","iterate","forEachSeries","define","amd","asyncCallback","createDB","pool","getOrCreate","MemoryContext","readOnly","Memory","Default","Fallback","NotSupported","defaults","Environment","set","promisify","Path","minimatch","Shell","fs","options","defineProperty","enumerable","cd","stat","stats","ENOTDIR","type","pwd","promises","methodName","bind","sh","readFile","cmd","Function","touch","createFile","writeFile","updateTimes","now","Date","atime","date","mtime","utimes","updateOnly","cat","files","all","append","ls","pathname","readdir","entries","getDirEntry","entry","recursive","items","contents","rm","remove","unlink","rmdir","ENOTEMPTY","map","tempDir","tmp","mkdir","mkdirp","_mkdirp","isDirectory","isFile","parent","find","next","found","processPath","maybeProcessPath","rawPath","regex","test","walk","removeItem","EventEmitter","createInterface","space","methods","trigger","self","pvt","_on","_off","_trigger","pub","throttle","delay","extend","a","b","localStorage","window","getItem","setItem","Intercom","origin","lastMessage","receivedIDs","previousValues","storageHandler","_onStorageEvent","document","attachEvent","addEventListener","_transaction","TIMEOUT","WAIT","executed","listening","waitTimer","lock","activeLock","INDEX_LOCK","unlock","_cleanup_emit","threshold","THRESHOLD_TTL_EMIT","changed","messages","INDEX_EMIT","timestamp","_cleanup_once","ttl","table","INDEX_ONCE","_once_expired","THRESHOLD_TTL_ONCE","_localStorageChanged","field","currentValue","id","payload","_emit","String","packet","supported","destroy","getInstance","intercom","FSWatcher","recursivePathPrefix","onchange","filename_","persistent_","recursive_","close","string","DirectoryEntry","OpenFileDescription","flags","position","getNode","check_if_node_exists","node","EBADF","Constants","SuperNode","ctime","rnode","getMode","Node","xattrs","nlinks","uid","gid","ensureID","prop","setMode","Stats","fileNode","devName","dev","isSymbolicLink","isSocket","isFIFO","isCharacterDevice","isBlockDevice","_","isAbsolutePath","isNullPath","Encoding","update_node_times","times","update","complete","changes","make_node","parentPath","parentNode","parentNodeData","create_node_in_parent","parentDirectoryNode","find_node","EEXIST","ENOENT","create_node","update_parent_node_data","update_time","followedCount","read_root_directory_node","superNode","EFILESYSTEMERROR","check_root_directory_node","rootDirectoryNode","read_parent_directory_data","get_node_from_parent_directory_data","parentDirectoryData","nodeId","is_symbolic_link","ELOOP","follow_symbolic_link","set_extended_attribute","flag","ENOATTR","ensure_root_directory","directoryNode","directoryData","ensure_super_node","existingNode","write_directory_node","write_directory_data","make_directory","check_if_directory_exists","update_parent_directory_data","remove_directory","EBUSY","check_if_node_is_directory","check_if_directory_is_empty","remove_directory_entry_from_parent_directory_node","remove_directory_node","remove_directory_data","open_file","directoryEntry","fileData","EISDIR","set_file_node","read_directory_data","check_if_file_exists","check_if_symbolic_link","write_file_node","undefined","write_file_data","fill","update_directory_data","handle_update_result","replace_data","ofd","offset","return_nbytes","update_file_node","newData","copy","write_data","update_file_data","EIO","_position","newSize","max","read_file_data","read_data","handle_file_data","stat_file","fstat_file","lstat_file","link_node","oldpath","newpath","oldname","oldParentPath","newname","newParentPath","oldDirectoryNode","oldDirectoryData","newDirectoryNode","newDirectoryData","fileNodeID","read_file_node","check_if_new_file_exists","read_new_directory_data","check_if_old_file_exists","EPERM","read_old_directory_data","unlink_node","delete_file_data","read_directory","handle_directory_data","make_symbolic_link","srcpath","dstpath","symlink_relpath","read_link","check_if_symbolic","truncate_file","truncate_file_data","ftruncate_file","utimes_file","update_times","futimes_file","setxattr_file","setxattr","fsetxattr_file","getxattr_file","get_xattr","fgetxattr_file","removexattr_file","remove_xattr","fremovexattr_file","validate_flags","validate_file_options","enc","fileMode","pathCheck","allowRelative","check_result","openFileDescription","fd","allocDescriptor","openFiles","releaseDescriptor","mknod","validateAndMaskMode","fstat","link","read","wrapped_cb","bytesRead","cleanup","fstatResult","write","appendFile","exists","cb","console","warn","octalReg","isUint32","def","Number","isInteger","parsed","parseInt","chmod_file","update_mode","fchmod_file","chown_file","update_owner","fchown_file","getxattr","fgetxattr","fsetxattr","removexattr","fremovexattr","lseek","whence","update_descriptor_position","currentTime","futimes","chmod","fchmod","chown","fchown","rename","oldName","newName","oldParentDirectory","oldParentData","newParentDirectory","newParentData","read_new_directory","update_old_parent_directory_data","update_new_parent_directory_data","check_if_new_directory_exists","read_new_parent_directory_data","get_new_parent_directory","unlink_old_file","check_node_type","symlink","readlink","lstat","truncate","ftruncate","ensureRootDirectory","providers","defaultGuidFn","impl","maybeCallback","defaultCallback","FileSystem","provider","forceFormatting","readyState","stdin","stdout","stderr","constants","nextDescriptor","queueOrRun","operation","runQueued","watch","listener","watcher","wrappedGuidFn","guidWithCheck","broadcastChanges","change","wrappedContext","openReadWriteContext","openReadOnlyContext","lastArgIndex","missingCallback","fnArgs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAEA;;;;;;;AAOA,IAAIA,aAAaC,MAAMC,SAAvB;AACA,IAAIC,gBAAgBH,WAAWI,OAA/B;AACA,IAAIC,gBAAgBL,WAAWM,OAA/B;AACA,IAAIC,aAAaP,WAAWQ,IAA5B;;AAEA,IAAIC,WAAWC,OAAOR,SAAtB;AACA,IAAIS,iBAAiBF,SAASE,cAA9B;AACA,IAAIC,aAAaF,OAAOG,IAAxB;;AAEA,IAAIC,UAAU,EAAd;;AAEA,SAASC,GAAT,CAAaC,GAAb,EAAkBC,GAAlB,EAAuB;AACrB,SAAON,eAAeO,IAAf,CAAoBF,GA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wB,UAASE,GAAT,EAAc;AACpC,SAAOF,IAAI,KAAKS,KAAT,EAAgBP,GAAhB,CAAP;AACD,CAFD;AAGAkB,QAAQjC,SAAR,CAAkB+B,QAAlB,GAA6B,UAASC,MAAT,EAAiB;AAC5C,SAAOD,SAAS,KAAKT,KAAd,EAAqBU,MAArB,CAAP;AACD,CAFD;AAGAC,QAAQjC,SAAR,CAAkBmB,IAAlB,GAAyB,YAAW;AAClC,SAAOA,KAAK,KAAKG,KAAV,CAAP;AACD,CAFD;;AAIA,SAASY,MAAT,CAAgBZ,KAAhB,EAAuB;AACrB;AACA,SAAQA,SAAS,QAAOA,KAAP,yCAAOA,KAAP,MAAgB,QAAzB,IAAqC,CAACvB,MAAMoC,OAAN,CAAcb,KAAd,CAAtC,IAA8Db,eAAeO,IAAf,CAAoBM,KAApB,EAA2B,aAA3B,CAA/D,GACHA,KADG,GAEH,IAAIW,OAAJ,CAAYX,KAAZ,CAFJ;AAGD;;AAEDc,OAAOC,OAAP,GAAiBH,MAAjB;;AChGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACnFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA,SAASI,cAAT,CAAwBC,KAAxB,EAA+BC,cAA/B,EAA+C;AAC7C;AAC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AAa,OAjBF;AAkBXC,gBAAY,GAlBD;AAmBXC,YAAQ,GAnBG;AAoBXC,aAAS,OApBE;AAqBXC,eAAW,OArBA;AAsBXC,gBAAY,CAtBD;AAuBXC,aAAS,GAvBE;AAwBXC,aAAS,GAxBE;AAyBXC,aAAS,GAzBE;AA0BXC,aAAS,EA1BE;AA2BXC,aAAS,EA3BE;AA4BXC,aAAS,EA5BE;AA6BXC,aAAS,EA7BE;AA8BXC,aAAS,CA9BE;AA+BXC,aAAS,CA/BE;AAgCXC,aAAS,CAhCE;AAiCXC,aAAS,CAjCE;AAkCXC,aAAS,CAlCE;AAmCXC,UAAM,CAnCK;AAoCXC,UAAM,CApCK;AAqCXC,UAAM,CArCK;AAsCXC,UAAM,CAtCK;AAuCXC,yBAAqB,CAvCV;AAwCXC,mBAAe;AAxCJ;AAjFE,CAAjB;;ACTA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACvJA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACpFA;AACA;AACA;AACA;AACA;AACA;;;;ACLA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC7vDA,SAASC,WAAT,CAAsBC,OAAtB,EAA+BC,QAA/B,EAAyCC,OAAzC,EAAkD;;AAEhD;AACA;AACA,MAAIF,mBAAmBG,WAAvB,EAAoC;AAClCH,cAAU,IAAII,UAAJ,CAAeJ,OAAf,CAAV;AACD;;AAED,SAAO,IAAIK,MAAJ,CAAWL,OAAX,EAAoBC,QAApB,EAA8BC,OAA9B,CAAP;AACD;;AAED;AACAH,YAAY1L,SAAZ,GAAwBQ,OAAOyL,MAAP,CAAcD,OAAOhM,SAArB,CAAxB;AACA0L,YAAY1L,SAAZ,CAAsBkM,WAAtB,GAAoCR,WAApC;;AAEA;AACAlL,OAAOG,IAAP,CAAYqL,MAAZ,EAAoB9L,OAApB,CAA4B,UAAUuD,CAAV,EAAa;AACvC,MAAIuI,OAAOvL,cAAP,CAAsBgD,CAAtB,CAAJ,EAA8B;AAC5BiI,gBAAYjI,CAAZ,IAAiBuI,OAAOvI,CAAP,CAAjB;AACD;AACF,CAJD;;AAMArB,OAAOC,OAAP,GAAiBqJ,WAAjB;;;ACtBA,IAAI3E,mBAAmBoF,QAAQ,iBAAR,EAA2BpF,gBAAlD;AACA,IAAIC,kBAAkBmF,QAAQ,iBAAR,EAA2BnF,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EAAyB;AACvB,aAAOmD,MAAP;AACD;;AAED,aAASkE,YAAT,GAAwB;AACtB,YAAM,kEAAN;AACD;AACDA,iBAAarH,WAAb,GAA2B,YAAW;AACpC,aAAO,KAAP;AACD,KAFD;AAGA,WAAOqH,YAAP;AACD,GAhBU;AAbI,CAAjB;;ACJA,IAAIC,WAAW1J,QAAQ,iBAAR,EAA2BjD,WAA1C;;AAEA9G,OAAOC,OAAP,GAAiB,SAASyT,WAAT,CAAqBvC,GAArB,EAA0B;AACzCA,QAAMA,OAAO,EAAb;AACAA,MAAIpK,GAAJ,GAAUoK,IAAIpK,GAAJ,IAAW0M,SAAS1M,GAA9B;AACAoK,MAAInK,IAAJ,GAAWmK,IAAInK,IAAJ,IAAYyM,SAASzM,IAAhC;;AAEA,OAAKqE,GAAL,GAAW,UAASa,IAAT,EAAe;AACxB,WAAOiF,IAAIjF,IAAJ,CAAP;AACD,GAFD;;AAIA,OAAKyH,GAAL,GAAW,UAASzH,IAAT,EAAehN,KAAf,EAAsB;AAC/BiS,QAAIjF,IAAJ,IAAYhN,KAAZ;AACD,GAFD;AAGD,CAZD;;;ACFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AChOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACbA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC3DA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACzMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA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AGhiB,KAAH,EAAU;AACRN,iBAASM,KAAT;AACD;AACF,KA1CD;;AA4CAwgB,eAAW9tB,SAAX,CAAqB8W,QAArB,CAA8BC,UAA9B,IAA4Cf,UAAU8X,WAAW9tB,SAAX,CAAqB+W,UAArB,EAAiCC,IAAjC,CAAsCZ,EAAtC,CAAV,CAA5C;AACD,GAlFD;AAoFD;;AAED;AACA0X,WAAWL,SAAX,GAAuBA,SAAvB;;AAEArrB,OAAOC,OAAP,GAAiByrB,UAAjB;;ACtWA1rB,OAAOC,OAAP,GAAiB;AACfyrB,cAAY3hB,QAAQ,2BAAR,CADG;AAEfH,UAAQG,QAAQ,aAAR,CAFO;AAGf8J,QAAM9J,QAAQ,WAAR,CAHS;AAIfwE,UAAQxE,QAAQ,aAAR,CAJO;AAKfgK,SAAOhK,QAAQ,kBAAR;AALQ,CAAjB","file":"filer.map","sourceRoot":"..\\src","sourcesContent":["// Cherry-picked bits of underscore.js, lodash.js\r\n\r\n/**\r\n * Lo-Dash 2.4.0 <http://lodash.com/>\r\n * Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/>\r\n * Based on Underscore.js 1.5.2 <http://underscorejs.org/LICENSE>\r\n * Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors\r\n * Available under MIT license <http://lodash.com/license>\r\n */\r\nvar ArrayProto = Array.prototype;\r\nvar nativeForEach = ArrayProto.forEach;\r\nvar nativeIndexOf = ArrayProto.indexOf;\r\nvar nativeSome = ArrayProto.some;\r\n\r\nvar ObjProto = Object.prototype;\r\nvar hasOwnProperty = ObjProto.hasOwnProperty;\r\nvar nativeKeys = Object.keys;\r\n\r\nvar breaker = {};\r\n\r\nfunction has(obj, key) {\r\n return hasOwnProperty.call(obj, key);\r\n}\r\n\r\nvar keys = nativeKeys || function(obj) {\r\n if (obj !== Object(obj)) throw new TypeError('Invalid object');\r\n var keys = [];\r\n for (var key in obj) if (has(obj, key)) keys.push(key);\r\n return keys;\r\n};\r\n\r\nfunction size(obj) {\r\n if (obj == null) return 0;\r\n return (obj.length === +obj.length) ? obj.length : keys(obj).length;\r\n}\r\n\r\nfunction identity(value) {\r\n return value;\r\n}\r\n\r\nfunction each(obj, iterator, context) {\r\n var i, length;\r\n if (obj == null) return;\r\n if (nativeForEach && obj.forEach === nativeForEach) {\r\n obj.forEach(iterator, context);\r\n } else if (obj.length === +obj.length) {\r\n for (i = 0, length = obj.length; i < length; i++) {\r\n if (iterator.call(context, obj[i], i, obj) === breaker) return;\r\n }\r\n } else {\r\n var keys = keys(obj);\r\n for (i = 0, length = keys.length; i < length; i++) {\r\n if (iterator.call(context, obj[keys[i]], keys[i], obj) === breaker) return;\r\n }\r\n }\r\n};\r\n\r\nfunction any(obj, iterator, context) {\r\n iterator || (iterator = identity);\r\n var result = false;\r\n if (obj == null) return result;\r\n if (nativeSome && obj.some === nativeSome) return obj.some(iterator, context);\r\n each(obj, function(value, index, list) {\r\n if (result || (result = iterator.call(context, value, index, list))) return breaker;\r\n });\r\n return !!result;\r\n};\r\n\r\nfunction contains(obj, target) {\r\n if (obj == null) return false;\r\n if (nativeIndexOf && obj.indexOf === nativeIndexOf) return obj.indexOf(target) != -1;\r\n return any(obj, function(value) {\r\n return value === target;\r\n });\r\n};\r\n\r\nfunction Wrapped(value) {\r\n this.value = value;\r\n}\r\nWrapped.prototype.has = function(key) {\r\n return has(this.value, key);\r\n};\r\nWrapped.prototype.contains = function(target) {\r\n return contains(this.value, target);\r\n};\r\nWrapped.prototype.size = function() {\r\n return size(this.value);\r\n};\r\n\r\nfunction nodash(value) {\r\n // don't wrap if already wrapped, even if wrapped by a different `lodash` constructor\r\n return (value && typeof value == 'object' && !Array.isArray(value) && hasOwnProperty.call(value, '__wrapped__'))\r\n ? value\r\n : new Wrapped(value);\r\n}\r\n\r\nmodule.exports = nodash;\r\n","\"use strict\";\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n// Symbols is a better way to do this, but if we don't have support we'll just\n// have to make do with an unlikely token\nvar customArgumentsToken = Symbol ? Symbol(\"__ES6-PROMISIFY--CUSTOM-ARGUMENTS__\") : \"__ES6-PROMISIFY--CUSTOM-ARGUMENTS__\";\n\n/**\n * promisify()\n * Transforms callback-based function -- func(arg1, arg2 .. argN, callback) -- into\n * an ES6-compatible Promise. Promisify provides a default callback of the form (error, result)\n * and rejects when `error` is truthy.\n *\n * @param {function} original - The function to promisify\n * @return {function} A promisified version of `original`\n */\nfunction promisify(original) {\n\n // Ensure the argument is a function\n if (typeof original !== \"function\") {\n throw new TypeError(\"Argument to promisify must be a function\");\n }\n\n // If the user has asked us to decode argument names for them, honour that\n var argumentNames = original[customArgumentsToken];\n\n // If the user has supplied a custom Promise implementation, use it. Otherwise\n // fall back to whatever we can find on the global object.\n var ES6Promise = promisify.Promise || Promise;\n\n // If we can find no Promise implemention, then fail now.\n if (typeof ES6Promise !== \"function\") {\n throw new Error(\"No Promise implementation found; do you need a polyfill?\");\n }\n\n return function () {\n var _this = this;\n\n for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n return new ES6Promise(function (resolve, reject) {\n\n // Append the callback bound to the context\n args.push(function callback(err) {\n\n if (err) {\n return reject(err);\n }\n\n for (var _len2 = arguments.length, values = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {\n values[_key2 - 1] = arguments[_key2];\n }\n\n if (values.length === 1 || !argumentNames) {\n return resolve(values[0]);\n }\n\n var o = {};\n values.forEach(function (value, index) {\n var name = argumentNames[index];\n if (name) {\n o[name] = value;\n }\n });\n\n resolve(o);\n });\n\n // Call the function.\n original.call.apply(original, [_this].concat(args));\n });\n };\n}\n\n// Attach this symbol to the exported function, so users can use it\npromisify.argumentNames = customArgumentsToken;\npromisify.Promise = undefined;\n\n// Export the public API\nexports.promisify = promisify;","// Copyright Joyent, Inc. and other Node contributors.\r\n//\r\n// Permission is hereby granted, free of charge, to any person obtaining a\r\n// copy of this software and associated documentation files (the\r\n// \"Software\"), to deal in the Software without restriction, including\r\n// without limitation the rights to use, copy, modify, merge, publish,\r\n// distribute, sublicense, and/or sell copies of the Software, and to permit\r\n// persons to whom the Software is furnished to do so, subject to the\r\n// following conditions:\r\n//\r\n// The above copyright notice and this permission notice shall be included\r\n// in all copies or substantial portions of the Software.\r\n//\r\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\r\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\r\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\r\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\r\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\r\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\r\n\r\n// Based on https://github.com/joyent/node/blob/41e53e557992a7d552a8e23de035f9463da25c99/lib/path.js\r\n\r\n// resolves . and .. elements in a path array with directory names there\r\n// must be no slashes, empty elements, or device names (c:\\) in the array\r\n// (so also no leading and trailing slashes - it does not distinguish\r\n// relative and absolute paths)\r\nfunction normalizeArray(parts, allowAboveRoot) {\r\n // if the path tries to go above the root, `up` ends up > 0\r\n var up = 0;\r\n for (var i = parts.length - 1; i >= 0; i--) {\r\n var last = parts[i];\r\n if (last === '.') {\r\n parts.splice(i, 1);\r\n } else if (last === '..') {\r\n parts.splice(i, 1);\r\n up++;\r\n } else if (up) {\r\n parts.splice(i, 1);\r\n up--;\r\n }\r\n }\r\n\r\n // if the path is allowed to go above the root, restore leading ..s\r\n if (allowAboveRoot) {\r\n for (; up--; up) {\r\n parts.unshift('..');\r\n }\r\n }\r\n\r\n return parts;\r\n}\r\n\r\n// Split a filename into [root, dir, basename, ext], unix version\r\n// 'root' is just a slash, or nothing.\r\nvar splitPathRe =\r\n /^(\\/?)([\\s\\S]+\\/(?!$)|\\/)?((?:\\.{1,2}$|[\\s\\S]+?)?(\\.[^./]*)?)$/;\r\nvar splitPath = function(filename) {\r\n var result = splitPathRe.exec(filename);\r\n return [result[1] || '', result[2] || '', result[3] || '', result[4] || ''];\r\n};\r\n\r\n// path.resolve([from ...], to)\r\nfunction resolve() {\r\n var resolvedPath = '',\r\n resolvedAbsolute = false;\r\n\r\n for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {\r\n // XXXfiler: we don't have process.cwd() so we use '/' as a fallback\r\n var path = (i >= 0) ? arguments[i] : '/';\r\n\r\n // Skip empty and invalid entries\r\n if (typeof path !== 'string' || !path) {\r\n continue;\r\n }\r\n\r\n resolvedPath = path + '/' + resolvedPath;\r\n resolvedAbsolute = path.charAt(0) === '/';\r\n }\r\n\r\n // At this point the path should be resolved to a full absolute path, but\r\n // handle relative paths to be safe (might happen when process.cwd() fails)\r\n\r\n // Normalize the path\r\n resolvedPath = normalizeArray(resolvedPath.split('/').filter(function(p) {\r\n return !!p;\r\n }), !resolvedAbsolute).join('/');\r\n\r\n return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';\r\n}\r\n\r\n// path.normalize(path)\r\nfunction normalize(path) {\r\n var isAbsolute = path.charAt(0) === '/';\r\n\r\n // Normalize the path\r\n path = normalizeArray(path.split('/').filter(function(p) {\r\n return !!p;\r\n }), !isAbsolute).join('/');\r\n\r\n if (!path && !isAbsolute) {\r\n path = '.';\r\n }\r\n /*\r\n if (path && trailingSlash) {\r\n path += '/';\r\n }\r\n */\r\n\r\n return (isAbsolute ? '/' : '') + path;\r\n}\r\n\r\nfunction join() {\r\n var paths = Array.prototype.slice.call(arguments, 0);\r\n return normalize(paths.filter(function(p) {\r\n return p && typeof p === 'string';\r\n }).join('/'));\r\n}\r\n\r\n// path.relative(from, to)\r\nfunction relative(from, to) {\r\n from = resolve(from).substr(1);\r\n to = resolve(to).substr(1);\r\n\r\n function trim(arr) {\r\n var start = 0;\r\n for (; start < arr.length; start++) {\r\n if (arr[start] !== '') break;\r\n }\r\n\r\n var end = arr.length - 1;\r\n for (; end >= 0; end--) {\r\n if (arr[end] !== '') break;\r\n }\r\n\r\n if (start > end) return [];\r\n return arr.slice(start, end - start + 1);\r\n }\r\n\r\n var fromParts = trim(from.split('/'));\r\n var toParts = trim(to.split('/'));\r\n\r\n var length = Math.min(fromParts.length, toParts.length);\r\n var samePartsLength = length;\r\n for (var i = 0; i < length; i++) {\r\n if (fromParts[i] !== toParts[i]) {\r\n samePartsLength = i;\r\n break;\r\n }\r\n }\r\n\r\n var outputParts = [];\r\n for (i = samePartsLength; i < fromParts.length; i++) {\r\n outputParts.push('..');\r\n }\r\n\r\n outputParts = outputParts.concat(toParts.slice(samePartsLength));\r\n\r\n return outputParts.join('/');\r\n}\r\n\r\nfunction dirname(path) {\r\n var result = splitPath(path),\r\n root = result[0],\r\n dir = result[1];\r\n\r\n if (!root && !dir) {\r\n // No dirname whatsoever\r\n return '.';\r\n }\r\n\r\n if (dir) {\r\n // It has a dirname, strip trailing slash\r\n dir = dir.substr(0, dir.length - 1);\r\n }\r\n\r\n return root + dir;\r\n}\r\n\r\nfunction basename(path, ext) {\r\n var f = splitPath(path)[2];\r\n // TODO: make this comparison case-insensitive on windows?\r\n if (ext && f.substr(-1 * ext.length) === ext) {\r\n f = f.substr(0, f.length - ext.length);\r\n }\r\n // XXXfiler: node.js just does `return f`\r\n return f === '' ? '/' : f;\r\n}\r\n\r\nfunction extname(path) {\r\n return splitPath(path)[3];\r\n}\r\n\r\nfunction isAbsolute(path) {\r\n if(path.charAt(0) === '/') {\r\n return true;\r\n }\r\n return false;\r\n}\r\n\r\nfunction isNull(path) {\r\n if (('' + path).indexOf('\\u0000') !== -1) {\r\n return true;\r\n }\r\n return false;\r\n}\r\n\r\n// Make sure we don't double-add a trailing slash (e.g., '/' -> '//')\r\nfunction addTrailing(path) {\r\n return path.replace(/\\/*$/, '/');\r\n}\r\n\r\n// Deal with multiple slashes at the end, one, or none\r\n// and make sure we don't return the empty string.\r\nfunction removeTrailing(path) {\r\n path = path.replace(/\\/*$/, '');\r\n return path === '' ? '/' : path;\r\n}\r\n\r\n// XXXfiler: we don't support path.exists() or path.existsSync(), which\r\n// are deprecated, and need a FileSystem instance to work. Use fs.stat().\r\n\r\nmodule.exports = {\r\n normalize: normalize,\r\n resolve: resolve,\r\n join: join,\r\n relative: relative,\r\n sep: '/',\r\n delimiter: ':',\r\n dirname: dirname,\r\n basename: basename,\r\n extname: extname,\r\n isAbsolute: isAbsolute,\r\n isNull: isNull,\r\n // Non-node but useful...\r\n addTrailing: addTrailing,\r\n removeTrailing: removeTrailing\r\n};\r\n","function guid() {\r\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {\r\n var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);\r\n return v.toString(16);\r\n }).toUpperCase();\r\n}\r\n\r\nfunction nop() {}\r\n\r\n/**\r\n * Convert a Uint8Array to a regular array\r\n */\r\nfunction u8toArray(u8) {\r\n var array = [];\r\n var len = u8.length;\r\n for(var i = 0; i < len; i++) {\r\n array[i] = u8[i];\r\n }\r\n return array;\r\n}\r\n\r\nmodule.exports = {\r\n guid: guid,\r\n u8toArray: u8toArray,\r\n nop: nop\r\n};\r\n","var O_READ = 'READ';\r\nvar O_WRITE = 'WRITE';\r\nvar O_CREATE = 'CREATE';\r\nvar O_EXCLUSIVE = 'EXCLUSIVE';\r\nvar O_TRUNCATE = 'TRUNCATE';\r\nvar O_APPEND = 'APPEND';\r\nvar XATTR_CREATE = 'CREATE';\r\nvar XATTR_REPLACE = 'REPLACE';\r\n\r\nmodule.exports = {\r\n FILE_SYSTEM_NAME: 'local',\r\n\r\n FILE_STORE_NAME: 'files',\r\n\r\n IDB_RO: 'readonly',\r\n IDB_RW: 'readwrite',\r\n\r\n WSQL_VERSION: '1',\r\n WSQL_SIZE: 5 * 1024 * 1024,\r\n WSQL_DESC: 'FileSystem Storage',\r\n\r\n NODE_TYPE_FILE: 'FILE',\r\n NODE_TYPE_DIRECTORY: 'DIRECTORY',\r\n NODE_TYPE_SYMBOLIC_LINK: 'SYMLINK',\r\n NODE_TYPE_META: 'META',\r\n\r\n S_IFREG: 0x8000,\r\n S_IFDIR: 0x4000,\r\n S_IFLNK: 0xA000,\r\n\r\n DEFAULT_DIR_PERMISSIONS: 0x1ED, // 755\r\n DEFAULT_FILE_PERMISSIONS: 0x1A4, // 644\r\n FULL_READ_WRITE_EXEC_PERMISSIONS: 0x1FF, // 777\r\n READ_WRITE_PERMISSIONS: 0x1B6, /// 666\r\n \r\n SYMLOOP_MAX: 10,\r\n\r\n BINARY_MIME_TYPE: 'application/octet-stream',\r\n JSON_MIME_TYPE: 'application/json',\r\n\r\n ROOT_DIRECTORY_NAME: '/', // basename(normalize(path))\r\n\r\n // FS Mount Flags\r\n FS_FORMAT: 'FORMAT',\r\n FS_NOCTIME: 'NOCTIME',\r\n FS_NOMTIME: 'NOMTIME',\r\n FS_NODUPEIDCHECK: 'FS_NODUPEIDCHECK',\r\n\r\n // FS File Open Flags\r\n O_READ: O_READ,\r\n O_WRITE: O_WRITE,\r\n O_CREATE: O_CREATE,\r\n O_EXCLUSIVE: O_EXCLUSIVE,\r\n O_TRUNCATE: O_TRUNCATE,\r\n O_APPEND: O_APPEND,\r\n\r\n O_FLAGS: {\r\n 'r': [O_READ],\r\n 'r+': [O_READ, O_WRITE],\r\n 'w': [O_WRITE, O_CREATE, O_TRUNCATE],\r\n 'w+': [O_WRITE, O_READ, O_CREATE, O_TRUNCATE],\r\n 'wx': [O_WRITE, O_CREATE, O_EXCLUSIVE, O_TRUNCATE],\r\n 'wx+': [O_WRITE, O_READ, O_CREATE, O_EXCLUSIVE, O_TRUNCATE],\r\n 'a': [O_WRITE, O_CREATE, O_APPEND],\r\n 'a+': [O_WRITE, O_READ, O_CREATE, O_APPEND],\r\n 'ax': [O_WRITE, O_CREATE, O_EXCLUSIVE, O_APPEND],\r\n 'ax+': [O_WRITE, O_READ, O_CREATE, O_EXCLUSIVE, O_APPEND]\r\n },\r\n\r\n XATTR_CREATE: XATTR_CREATE,\r\n XATTR_REPLACE: XATTR_REPLACE,\r\n\r\n FS_READY: 'READY',\r\n FS_PENDING: 'PENDING',\r\n FS_ERROR: 'ERROR',\r\n\r\n SUPER_NODE_ID: '00000000-0000-0000-0000-000000000000',\r\n\r\n // Reserved File Descriptors for streams\r\n STDIN: 0,\r\n STDOUT: 1,\r\n STDERR: 2,\r\n FIRST_DESCRIPTOR: 3,\r\n\r\n ENVIRONMENT: {\r\n TMP: '/tmp',\r\n PATH: ''\r\n },\r\n\r\n // Duplicate Node's fs.constants\r\n fsConstants: {\r\n O_RDONLY: 0,\r\n O_WRONLY: 1,\r\n O_RDWR: 2,\r\n S_IFMT: 61440,\r\n S_IFREG: 32768,\r\n S_IFDIR: 16384,\r\n S_IFCHR: 8192,\r\n S_IFBLK: 24576,\r\n S_IFIFO: 4096,\r\n S_IFLNK: 40960,\r\n S_IFSOCK: 49152,\r\n O_CREAT: 512,\r\n O_EXCL: 2048,\r\n O_NOCTTY: 131072,\r\n O_TRUNC: 1024,\r\n O_APPEND: 8,\r\n O_DIRECTORY: 1048576,\r\n O_NOFOLLOW: 256,\r\n O_SYNC: 128,\r\n O_DSYNC: 4194304,\r\n O_SYMLINK: 2097152,\r\n O_NONBLOCK: 4,\r\n S_IRWXU: 448,\r\n S_IRUSR: 256,\r\n S_IWUSR: 128,\r\n S_IXUSR: 64,\r\n S_IRWXG: 56,\r\n S_IRGRP: 32,\r\n S_IWGRP: 16,\r\n S_IXGRP: 8,\r\n S_IRWXO: 7,\r\n S_IROTH: 4,\r\n S_IWOTH: 2,\r\n S_IXOTH: 1,\r\n F_OK: 0,\r\n R_OK: 4,\r\n W_OK: 2,\r\n X_OK: 1,\r\n UV_FS_COPYFILE_EXCL: 1,\r\n COPYFILE_EXCL: 1\r\n }\r\n};\r\n","'use strict'\n\nexports.byteLength = byteLength\nexports.toByteArray = toByteArray\nexports.fromByteArray = fromByteArray\n\nvar lookup = []\nvar revLookup = []\nvar Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array\n\nvar code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'\nfor (var i = 0, len = code.length; i < len; ++i) {\n lookup[i] = code[i]\n revLookup[code.charCodeAt(i)] = i\n}\n\n// Support decoding URL-safe base64 strings, as Node.js does.\n// See: https://en.wikipedia.org/wiki/Base64#URL_applications\nrevLookup['-'.charCodeAt(0)] = 62\nrevLookup['_'.charCodeAt(0)] = 63\n\nfunction getLens (b64) {\n var len = b64.length\n\n if (len % 4 > 0) {\n throw new Error('Invalid string. Length must be a multiple of 4')\n }\n\n // Trim off extra bytes after placeholder bytes are found\n // See: https://github.com/beatgammit/base64-js/issues/42\n var validLen = b64.indexOf('=')\n if (validLen === -1) validLen = len\n\n var placeHoldersLen = validLen === len\n ? 0\n : 4 - (validLen % 4)\n\n return [validLen, placeHoldersLen]\n}\n\n// base64 is 4/3 + up to two characters of the original data\nfunction byteLength (b64) {\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction _byteLength (b64, validLen, placeHoldersLen) {\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction toByteArray (b64) {\n var tmp\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n\n var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))\n\n var curByte = 0\n\n // if there are placeholders, only get up to the last complete 4 chars\n var len = placeHoldersLen > 0\n ? validLen - 4\n : validLen\n\n for (var i = 0; i < len; i += 4) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 18) |\n (revLookup[b64.charCodeAt(i + 1)] << 12) |\n (revLookup[b64.charCodeAt(i + 2)] << 6) |\n revLookup[b64.charCodeAt(i + 3)]\n arr[curByte++] = (tmp >> 16) & 0xFF\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 2) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 2) |\n (revLookup[b64.charCodeAt(i + 1)] >> 4)\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 1) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 10) |\n (revLookup[b64.charCodeAt(i + 1)] << 4) |\n (revLookup[b64.charCodeAt(i + 2)] >> 2)\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n return arr\n}\n\nfunction tripletToBase64 (num) {\n return lookup[num >> 18 & 0x3F] +\n lookup[num >> 12 & 0x3F] +\n lookup[num >> 6 & 0x3F] +\n lookup[num & 0x3F]\n}\n\nfunction encodeChunk (uint8, start, end) {\n var tmp\n var output = []\n for (var i = start; i < end; i += 3) {\n tmp =\n ((uint8[i] << 16) & 0xFF0000) +\n ((uint8[i + 1] << 8) & 0xFF00) +\n (uint8[i + 2] & 0xFF)\n output.push(tripletToBase64(tmp))\n }\n return output.join('')\n}\n\nfunction fromByteArray (uint8) {\n var tmp\n var len = uint8.length\n var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes\n var parts = []\n var maxChunkLength = 16383 // must be multiple of 3\n\n // go through the array every three bytes, we'll deal with trailing stuff later\n for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {\n parts.push(encodeChunk(\n uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)\n ))\n }\n\n // pad the end with zeros, but make sure to not forget the extra bytes\n if (extraBytes === 1) {\n tmp = uint8[len - 1]\n parts.push(\n lookup[tmp >> 2] +\n lookup[(tmp << 4) & 0x3F] +\n '=='\n )\n } else if (extraBytes === 2) {\n tmp = (uint8[len - 2] << 8) + uint8[len - 1]\n parts.push(\n lookup[tmp >> 10] +\n lookup[(tmp >> 4) & 0x3F] +\n lookup[(tmp << 2) & 0x3F] +\n '='\n )\n }\n\n return parts.join('')\n}\n","exports.read = function (buffer, offset, isLE, mLen, nBytes) {\n var e, m\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var nBits = -7\n var i = isLE ? (nBytes - 1) : 0\n var d = isLE ? -1 : 1\n var s = buffer[offset + i]\n\n i += d\n\n e = s & ((1 << (-nBits)) - 1)\n s >>= (-nBits)\n nBits += eLen\n for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n m = e & ((1 << (-nBits)) - 1)\n e >>= (-nBits)\n nBits += mLen\n for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n if (e === 0) {\n e = 1 - eBias\n } else if (e === eMax) {\n return m ? NaN : ((s ? -1 : 1) * Infinity)\n } else {\n m = m + Math.pow(2, mLen)\n e = e - eBias\n }\n return (s ? -1 : 1) * m * Math.pow(2, e - mLen)\n}\n\nexports.write = function (buffer, value, offset, isLE, mLen, nBytes) {\n var e, m, c\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)\n var i = isLE ? 0 : (nBytes - 1)\n var d = isLE ? 1 : -1\n var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0\n\n value = Math.abs(value)\n\n if (isNaN(value) || value === Infinity) {\n m = isNaN(value) ? 1 : 0\n e = eMax\n } else {\n e = Math.floor(Math.log(value) / Math.LN2)\n if (value * (c = Math.pow(2, -e)) < 1) {\n e--\n c *= 2\n }\n if (e + eBias >= 1) {\n value += rt / c\n } else {\n value += rt * Math.pow(2, 1 - eBias)\n }\n if (value * c >= 2) {\n e++\n c /= 2\n }\n\n if (e + eBias >= eMax) {\n m = 0\n e = eMax\n } else if (e + eBias >= 1) {\n m = ((value * c) - 1) * Math.pow(2, mLen)\n e = e + eBias\n } else {\n m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)\n e = 0\n }\n }\n\n for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}\n\n e = (e << mLen) | m\n eLen += mLen\n for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}\n\n buffer[offset + i - d] |= s * 128\n}\n","var toString = {}.toString;\n\nmodule.exports = Array.isArray || function (arr) {\n return toString.call(arr) == '[object Array]';\n};\n","/*!\n * The buffer module from node.js, for the browser.\n *\n * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>\n * @license MIT\n */\n/* eslint-disable no-proto */\n\n'use strict'\n\nvar base64 = require('base64-js')\nvar ieee754 = require('ieee754')\nvar isArray = require('isarray')\n\nexports.Buffer = Buffer\nexports.SlowBuffer = SlowBuffer\nexports.INSPECT_MAX_BYTES = 50\n\n/**\n * If `Buffer.TYPED_ARRAY_SUPPORT`:\n * === true Use Uint8Array implementation (fastest)\n * === false Use Object implementation (most compatible, even IE6)\n *\n * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,\n * Opera 11.6+, iOS 4.2+.\n *\n * Due to various browser bugs, sometimes the Object implementation will be used even\n * when the browser supports typed arrays.\n *\n * Note:\n *\n * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,\n * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.\n *\n * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.\n *\n * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of\n * incorrect length in some situations.\n\n * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they\n * get the Object implementation, which is slower but behaves correctly.\n */\nBuffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined\n ? global.TYPED_ARRAY_SUPPORT\n : typedArraySupport()\n\n/*\n * Export kMaxLength after typed array support is determined.\n */\nexports.kMaxLength = kMaxLength()\n\nfunction typedArraySupport () {\n try {\n var arr = new Uint8Array(1)\n arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}\n return arr.foo() === 42 && // typed array instances can be augmented\n typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`\n arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`\n } catch (e) {\n return false\n }\n}\n\nfunction kMaxLength () {\n return Buffer.TYPED_ARRAY_SUPPORT\n ? 0x7fffffff\n : 0x3fffffff\n}\n\nfunction createBuffer (that, length) {\n if (kMaxLength() < length) {\n throw new RangeError('Invalid typed array length')\n }\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n // Return an augmented `Uint8Array` instance, for best performance\n that = new Uint8Array(length)\n that.__proto__ = Buffer.prototype\n } else {\n // Fallback: Return an object instance of the Buffer class\n if (that === null) {\n that = new Buffer(length)\n }\n that.length = length\n }\n\n return that\n}\n\n/**\n * The Buffer constructor returns instances of `Uint8Array` that have their\n * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of\n * `Uint8Array`, so the returned instances will have all the node `Buffer` methods\n * and the `Uint8Array` methods. Square bracket notation works as expected -- it\n * returns a single octet.\n *\n * The `Uint8Array` prototype remains unmodified.\n */\n\nfunction Buffer (arg, encodingOrOffset, length) {\n if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {\n return new Buffer(arg, encodingOrOffset, length)\n }\n\n // Common case.\n if (typeof arg === 'number') {\n if (typeof encodingOrOffset === 'string') {\n throw new Error(\n 'If encoding is specified then the first argument must be a string'\n )\n }\n return allocUnsafe(this, arg)\n }\n return from(this, arg, encodingOrOffset, length)\n}\n\nBuffer.poolSize = 8192 // not used by this implementation\n\n// TODO: Legacy, not needed anymore. Remove in next major version.\nBuffer._augment = function (arr) {\n arr.__proto__ = Buffer.prototype\n return arr\n}\n\nfunction from (that, value, encodingOrOffset, length) {\n if (typeof value === 'number') {\n throw new TypeError('\"value\" argument must not be a number')\n }\n\n if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {\n return fromArrayBuffer(that, value, encodingOrOffset, length)\n }\n\n if (typeof value === 'string') {\n return fromString(that, value, encodingOrOffset)\n }\n\n return fromObject(that, value)\n}\n\n/**\n * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError\n * if value is a number.\n * Buffer.from(str[, encoding])\n * Buffer.from(array)\n * Buffer.from(buffer)\n * Buffer.from(arrayBuffer[, byteOffset[, length]])\n **/\nBuffer.from = function (value, encodingOrOffset, length) {\n return from(null, value, encodingOrOffset, length)\n}\n\nif (Buffer.TYPED_ARRAY_SUPPORT) {\n Buffer.prototype.__proto__ = Uint8Array.prototype\n Buffer.__proto__ = Uint8Array\n if (typeof Symbol !== 'undefined' && Symbol.species &&\n Buffer[Symbol.species] === Buffer) {\n // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97\n Object.defineProperty(Buffer, Symbol.species, {\n value: null,\n configurable: true\n })\n }\n}\n\nfunction assertSize (size) {\n if (typeof size !== 'number') {\n throw new TypeError('\"size\" argument must be a number')\n } else if (size < 0) {\n throw new RangeError('\"size\" argument must not be negative')\n }\n}\n\nfunction alloc (that, size, fill, encoding) {\n assertSize(size)\n if (size <= 0) {\n return createBuffer(that, size)\n }\n if (fill !== undefined) {\n // Only pay attention to encoding if it's a string. This\n // prevents accidentally sending in a number that would\n // be interpretted as a start offset.\n return typeof encoding === 'string'\n ? createBuffer(that, size).fill(fill, encoding)\n : createBuffer(that, size).fill(fill)\n }\n return createBuffer(that, size)\n}\n\n/**\n * Creates a new filled Buffer instance.\n * alloc(size[, fill[, encoding]])\n **/\nBuffer.alloc = function (size, fill, encoding) {\n return alloc(null, size, fill, encoding)\n}\n\nfunction allocUnsafe (that, size) {\n assertSize(size)\n that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)\n if (!Buffer.TYPED_ARRAY_SUPPORT) {\n for (var i = 0; i < size; ++i) {\n that[i] = 0\n }\n }\n return that\n}\n\n/**\n * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.\n * */\nBuffer.allocUnsafe = function (size) {\n return allocUnsafe(null, size)\n}\n/**\n * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.\n */\nBuffer.allocUnsafeSlow = function (size) {\n return allocUnsafe(null, size)\n}\n\nfunction fromString (that, string, encoding) {\n if (typeof encoding !== 'string' || encoding === '') {\n encoding = 'utf8'\n }\n\n if (!Buffer.isEncoding(encoding)) {\n throw new TypeError('\"encoding\" must be a valid string encoding')\n }\n\n var length = byteLength(string, encoding) | 0\n that = createBuffer(that, length)\n\n var actual = that.write(string, encoding)\n\n if (actual !== length) {\n // Writing a hex string, for example, that contains invalid characters will\n // cause everything after the first invalid character to be ignored. (e.g.\n // 'abxxcd' will be treated as 'ab')\n that = that.slice(0, actual)\n }\n\n return that\n}\n\nfunction fromArrayLike (that, array) {\n var length = array.length < 0 ? 0 : checked(array.length) | 0\n that = createBuffer(that, length)\n for (var i = 0; i < length; i += 1) {\n that[i] = array[i] & 255\n }\n return that\n}\n\nfunction fromArrayBuffer (that, array, byteOffset, length) {\n array.byteLength // this throws if `array` is not a valid ArrayBuffer\n\n if (byteOffset < 0 || array.byteLength < byteOffset) {\n throw new RangeError('\\'offset\\' is out of bounds')\n }\n\n if (array.byteLength < byteOffset + (length || 0)) {\n throw new RangeError('\\'length\\' is out of bounds')\n }\n\n if (byteOffset === undefined && length === undefined) {\n array = new Uint8Array(array)\n } else if (length === undefined) {\n array = new Uint8Array(array, byteOffset)\n } else {\n array = new Uint8Array(array, byteOffset, length)\n }\n\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n // Return an augmented `Uint8Array` instance, for best performance\n that = array\n that.__proto__ = Buffer.prototype\n } else {\n // Fallback: Return an object instance of the Buffer class\n that = fromArrayLike(that, array)\n }\n return that\n}\n\nfunction fromObject (that, obj) {\n if (Buffer.isBuffer(obj)) {\n var len = checked(obj.length) | 0\n that = createBuffer(that, len)\n\n if (that.length === 0) {\n return that\n }\n\n obj.copy(that, 0, 0, len)\n return that\n }\n\n if (obj) {\n if ((typeof ArrayBuffer !== 'undefined' &&\n obj.buffer instanceof ArrayBuffer) || 'length' in obj) {\n if (typeof obj.length !== 'number' || isnan(obj.length)) {\n return createBuffer(that, 0)\n }\n return fromArrayLike(that, obj)\n }\n\n if (obj.type === 'Buffer' && isArray(obj.data)) {\n return fromArrayLike(that, obj.data)\n }\n }\n\n throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')\n}\n\nfunction checked (length) {\n // Note: cannot use `length < kMaxLength()` here because that fails when\n // length is NaN (which is otherwise coerced to zero.)\n if (length >= kMaxLength()) {\n throw new RangeError('Attempt to allocate Buffer larger than maximum ' +\n 'size: 0x' + kMaxLength().toString(16) + ' bytes')\n }\n return length | 0\n}\n\nfunction SlowBuffer (length) {\n if (+length != length) { // eslint-disable-line eqeqeq\n length = 0\n }\n return Buffer.alloc(+length)\n}\n\nBuffer.isBuffer = function isBuffer (b) {\n return !!(b != null && b._isBuffer)\n}\n\nBuffer.compare = function compare (a, b) {\n if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {\n throw new TypeError('Arguments must be Buffers')\n }\n\n if (a === b) return 0\n\n var x = a.length\n var y = b.length\n\n for (var i = 0, len = Math.min(x, y); i < len; ++i) {\n if (a[i] !== b[i]) {\n x = a[i]\n y = b[i]\n break\n }\n }\n\n if (x < y) return -1\n if (y < x) return 1\n return 0\n}\n\nBuffer.isEncoding = function isEncoding (encoding) {\n switch (String(encoding).toLowerCase()) {\n case 'hex':\n case 'utf8':\n case 'utf-8':\n case 'ascii':\n case 'latin1':\n case 'binary':\n case 'base64':\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return true\n default:\n return false\n }\n}\n\nBuffer.concat = function concat (list, length) {\n if (!isArray(list)) {\n throw new TypeError('\"list\" argument must be an Array of Buffers')\n }\n\n if (list.length === 0) {\n return Buffer.alloc(0)\n }\n\n var i\n if (length === undefined) {\n length = 0\n for (i = 0; i < list.length; ++i) {\n length += list[i].length\n }\n }\n\n var buffer = Buffer.allocUnsafe(length)\n var pos = 0\n for (i = 0; i < list.length; ++i) {\n var buf = list[i]\n if (!Buffer.isBuffer(buf)) {\n throw new TypeError('\"list\" argument must be an Array of Buffers')\n }\n buf.copy(buffer, pos)\n pos += buf.length\n }\n return buffer\n}\n\nfunction byteLength (string, encoding) {\n if (Buffer.isBuffer(string)) {\n return string.length\n }\n if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&\n (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {\n return string.byteLength\n }\n if (typeof string !== 'string') {\n string = '' + string\n }\n\n var len = string.length\n if (len === 0) return 0\n\n // Use a for loop to avoid recursion\n var loweredCase = false\n for (;;) {\n switch (encoding) {\n case 'ascii':\n case 'latin1':\n case 'binary':\n return len\n case 'utf8':\n case 'utf-8':\n case undefined:\n return utf8ToBytes(string).length\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return len * 2\n case 'hex':\n return len >>> 1\n case 'base64':\n return base64ToBytes(string).length\n default:\n if (loweredCase) return utf8ToBytes(string).length // assume utf8\n encoding = ('' + encoding).toLowerCase()\n loweredCase = true\n }\n }\n}\nBuffer.byteLength = byteLength\n\nfunction slowToString (encoding, start, end) {\n var loweredCase = false\n\n // No need to verify that \"this.length <= MAX_UINT32\" since it's a read-only\n // property of a typed array.\n\n // This behaves neither like String nor Uint8Array in that we set start/end\n // to their upper/lower bounds if the value passed is out of range.\n // undefined is handled specially as per ECMA-262 6th Edition,\n // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.\n if (start === undefined || start < 0) {\n start = 0\n }\n // Return early if start > this.length. Done here to prevent potential uint32\n // coercion fail below.\n if (start > this.length) {\n return ''\n }\n\n if (end === undefined || end > this.length) {\n end = this.length\n }\n\n if (end <= 0) {\n return ''\n }\n\n // Force coersion to uint32. This will also coerce falsey/NaN values to 0.\n end >>>= 0\n start >>>= 0\n\n if (end <= start) {\n return ''\n }\n\n if (!encoding) encoding = 'utf8'\n\n while (true) {\n switch (encoding) {\n case 'hex':\n return hexSlice(this, start, end)\n\n case 'utf8':\n case 'utf-8':\n return utf8Slice(this, start, end)\n\n case 'ascii':\n return asciiSlice(this, start, end)\n\n case 'latin1':\n case 'binary':\n return latin1Slice(this, start, end)\n\n case 'base64':\n return base64Slice(this, start, end)\n\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return utf16leSlice(this, start, end)\n\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n encoding = (encoding + '').toLowerCase()\n loweredCase = true\n }\n }\n}\n\n// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect\n// Buffer instances.\nBuffer.prototype._isBuffer = true\n\nfunction swap (b, n, m) {\n var i = b[n]\n b[n] = b[m]\n b[m] = i\n}\n\nBuffer.prototype.swap16 = function swap16 () {\n var len = this.length\n if (len % 2 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 16-bits')\n }\n for (var i = 0; i < len; i += 2) {\n swap(this, i, i + 1)\n }\n return this\n}\n\nBuffer.prototype.swap32 = function swap32 () {\n var len = this.length\n if (len % 4 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 32-bits')\n }\n for (var i = 0; i < len; i += 4) {\n swap(this, i, i + 3)\n swap(this, i + 1, i + 2)\n }\n return this\n}\n\nBuffer.prototype.swap64 = function swap64 () {\n var len = this.length\n if (len % 8 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 64-bits')\n }\n for (var i = 0; i < len; i += 8) {\n swap(this, i, i + 7)\n swap(this, i + 1, i + 6)\n swap(this, i + 2, i + 5)\n swap(this, i + 3, i + 4)\n }\n return this\n}\n\nBuffer.prototype.toString = function toString () {\n var length = this.length | 0\n if (length === 0) return ''\n if (arguments.length === 0) return utf8Slice(this, 0, length)\n return slowToString.apply(this, arguments)\n}\n\nBuffer.prototype.equals = function equals (b) {\n if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')\n if (this === b) return true\n return Buffer.compare(this, b) === 0\n}\n\nBuffer.prototype.inspect = function inspect () {\n var str = ''\n var max = exports.INSPECT_MAX_BYTES\n if (this.length > 0) {\n str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')\n if (this.length > max) str += ' ... '\n }\n return '<Buffer ' + str + '>'\n}\n\nBuffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {\n if (!Buffer.isBuffer(target)) {\n throw new TypeError('Argument must be a Buffer')\n }\n\n if (start === undefined) {\n start = 0\n }\n if (end === undefined) {\n end = target ? target.length : 0\n }\n if (thisStart === undefined) {\n thisStart = 0\n }\n if (thisEnd === undefined) {\n thisEnd = this.length\n }\n\n if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {\n throw new RangeError('out of range index')\n }\n\n if (thisStart >= thisEnd && start >= end) {\n return 0\n }\n if (thisStart >= thisEnd) {\n return -1\n }\n if (start >= end) {\n return 1\n }\n\n start >>>= 0\n end >>>= 0\n thisStart >>>= 0\n thisEnd >>>= 0\n\n if (this === target) return 0\n\n var x = thisEnd - thisStart\n var y = end - start\n var len = Math.min(x, y)\n\n var thisCopy = this.slice(thisStart, thisEnd)\n var targetCopy = target.slice(start, end)\n\n for (var i = 0; i < len; ++i) {\n if (thisCopy[i] !== targetCopy[i]) {\n x = thisCopy[i]\n y = targetCopy[i]\n break\n }\n }\n\n if (x < y) return -1\n if (y < x) return 1\n return 0\n}\n\n// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,\n// OR the last index of `val` in `buffer` at offset <= `byteOffset`.\n//\n// Arguments:\n// - buffer - a Buffer to search\n// - val - a string, Buffer, or number\n// - byteOffset - an index into `buffer`; will be clamped to an int32\n// - encoding - an optional encoding, relevant is val is a string\n// - dir - true for indexOf, false for lastIndexOf\nfunction bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {\n // Empty buffer means no match\n if (buffer.length === 0) return -1\n\n // Normalize byteOffset\n if (typeof byteOffset === 'string') {\n encoding = byteOffset\n byteOffset = 0\n } else if (byteOffset > 0x7fffffff) {\n byteOffset = 0x7fffffff\n } else if (byteOffset < -0x80000000) {\n byteOffset = -0x80000000\n }\n byteOffset = +byteOffset // Coerce to Number.\n if (isNaN(byteOffset)) {\n // byteOffset: it it's undefined, null, NaN, \"foo\", etc, search whole buffer\n byteOffset = dir ? 0 : (buffer.length - 1)\n }\n\n // Normalize byteOffset: negative offsets start from the end of the buffer\n if (byteOffset < 0) byteOffset = buffer.length + byteOffset\n if (byteOffset >= buffer.length) {\n if (dir) return -1\n else byteOffset = buffer.length - 1\n } else if (byteOffset < 0) {\n if (dir) byteOffset = 0\n else return -1\n }\n\n // Normalize val\n if (typeof val === 'string') {\n val = Buffer.from(val, encoding)\n }\n\n // Finally, search either indexOf (if dir is true) or lastIndexOf\n if (Buffer.isBuffer(val)) {\n // Special case: looking for empty string/buffer always fails\n if (val.length === 0) {\n return -1\n }\n return arrayIndexOf(buffer, val, byteOffset, encoding, dir)\n } else if (typeof val === 'number') {\n val = val & 0xFF // Search for a byte value [0-255]\n if (Buffer.TYPED_ARRAY_SUPPORT &&\n typeof Uint8Array.prototype.indexOf === 'function') {\n if (dir) {\n return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)\n } else {\n return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)\n }\n }\n return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)\n }\n\n throw new TypeError('val must be string, number or Buffer')\n}\n\nfunction arrayIndexOf (arr, val, byteOffset, encoding, dir) {\n var indexSize = 1\n var arrLength = arr.length\n var valLength = val.length\n\n if (encoding !== undefined) {\n encoding = String(encoding).toLowerCase()\n if (encoding === 'ucs2' || encoding === 'ucs-2' ||\n encoding === 'utf16le' || encoding === 'utf-16le') {\n if (arr.length < 2 || val.length < 2) {\n return -1\n }\n indexSize = 2\n arrLength /= 2\n valLength /= 2\n byteOffset /= 2\n }\n }\n\n function read (buf, i) {\n if (indexSize === 1) {\n return buf[i]\n } else {\n return buf.readUInt16BE(i * indexSize)\n }\n }\n\n var i\n if (dir) {\n var foundIndex = -1\n for (i = byteOffset; i < arrLength; i++) {\n if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {\n if (foundIndex === -1) foundIndex = i\n if (i - foundIndex + 1 === valLength) return foundIndex * indexSize\n } else {\n if (foundIndex !== -1) i -= i - foundIndex\n foundIndex = -1\n }\n }\n } else {\n if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength\n for (i = byteOffset; i >= 0; i--) {\n var found = true\n for (var j = 0; j < valLength; j++) {\n if (read(arr, i + j) !== read(val, j)) {\n found = false\n break\n }\n }\n if (found) return i\n }\n }\n\n return -1\n}\n\nBuffer.prototype.includes = function includes (val, byteOffset, encoding) {\n return this.indexOf(val, byteOffset, encoding) !== -1\n}\n\nBuffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, true)\n}\n\nBuffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, false)\n}\n\nfunction hexWrite (buf, string, offset, length) {\n offset = Number(offset) || 0\n var remaining = buf.length - offset\n if (!length) {\n length = remaining\n } else {\n length = Number(length)\n if (length > remaining) {\n length = remaining\n }\n }\n\n // must be an even number of digits\n var strLen = string.length\n if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')\n\n if (length > strLen / 2) {\n length = strLen / 2\n }\n for (var i = 0; i < length; ++i) {\n var parsed = parseInt(string.substr(i * 2, 2), 16)\n if (isNaN(parsed)) return i\n buf[offset + i] = parsed\n }\n return i\n}\n\nfunction utf8Write (buf, string, offset, length) {\n return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nfunction asciiWrite (buf, string, offset, length) {\n return blitBuffer(asciiToBytes(string), buf, offset, length)\n}\n\nfunction latin1Write (buf, string, offset, length) {\n return asciiWrite(buf, string, offset, length)\n}\n\nfunction base64Write (buf, string, offset, length) {\n return blitBuffer(base64ToBytes(string), buf, offset, length)\n}\n\nfunction ucs2Write (buf, string, offset, length) {\n return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nBuffer.prototype.write = function write (string, offset, length, encoding) {\n // Buffer#write(string)\n if (offset === undefined) {\n encoding = 'utf8'\n length = this.length\n offset = 0\n // Buffer#write(string, encoding)\n } else if (length === undefined && typeof offset === 'string') {\n encoding = offset\n length = this.length\n offset = 0\n // Buffer#write(string, offset[, length][, encoding])\n } else if (isFinite(offset)) {\n offset = offset | 0\n if (isFinite(length)) {\n length = length | 0\n if (encoding === undefined) encoding = 'utf8'\n } else {\n encoding = length\n length = undefined\n }\n // legacy write(string, encoding, offset, length) - remove in v0.13\n } else {\n throw new Error(\n 'Buffer.write(string, encoding, offset[, length]) is no longer supported'\n )\n }\n\n var remaining = this.length - offset\n if (length === undefined || length > remaining) length = remaining\n\n if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {\n throw new RangeError('Attempt to write outside buffer bounds')\n }\n\n if (!encoding) encoding = 'utf8'\n\n var loweredCase = false\n for (;;) {\n switch (encoding) {\n case 'hex':\n return hexWrite(this, string, offset, length)\n\n case 'utf8':\n case 'utf-8':\n return utf8Write(this, string, offset, length)\n\n case 'ascii':\n return asciiWrite(this, string, offset, length)\n\n case 'latin1':\n case 'binary':\n return latin1Write(this, string, offset, length)\n\n case 'base64':\n // Warning: maxLength not taken into account in base64Write\n return base64Write(this, string, offset, length)\n\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return ucs2Write(this, string, offset, length)\n\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n encoding = ('' + encoding).toLowerCase()\n loweredCase = true\n }\n }\n}\n\nBuffer.prototype.toJSON = function toJSON () {\n return {\n type: 'Buffer',\n data: Array.prototype.slice.call(this._arr || this, 0)\n }\n}\n\nfunction base64Slice (buf, start, end) {\n if (start === 0 && end === buf.length) {\n return base64.fromByteArray(buf)\n } else {\n return base64.fromByteArray(buf.slice(start, end))\n }\n}\n\nfunction utf8Slice (buf, start, end) {\n end = Math.min(buf.length, end)\n var res = []\n\n var i = start\n while (i < end) {\n var firstByte = buf[i]\n var codePoint = null\n var bytesPerSequence = (firstByte > 0xEF) ? 4\n : (firstByte > 0xDF) ? 3\n : (firstByte > 0xBF) ? 2\n : 1\n\n if (i + bytesPerSequence <= end) {\n var secondByte, thirdByte, fourthByte, tempCodePoint\n\n switch (bytesPerSequence) {\n case 1:\n if (firstByte < 0x80) {\n codePoint = firstByte\n }\n break\n case 2:\n secondByte = buf[i + 1]\n if ((secondByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)\n if (tempCodePoint > 0x7F) {\n codePoint = tempCodePoint\n }\n }\n break\n case 3:\n secondByte = buf[i + 1]\n thirdByte = buf[i + 2]\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)\n if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {\n codePoint = tempCodePoint\n }\n }\n break\n case 4:\n secondByte = buf[i + 1]\n thirdByte = buf[i + 2]\n fourthByte = buf[i + 3]\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)\n if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {\n codePoint = tempCodePoint\n }\n }\n }\n }\n\n if (codePoint === null) {\n // we did not generate a valid codePoint so insert a\n // replacement char (U+FFFD) and advance only 1 byte\n codePoint = 0xFFFD\n bytesPerSequence = 1\n } else if (codePoint > 0xFFFF) {\n // encode to utf16 (surrogate pair dance)\n codePoint -= 0x10000\n res.push(codePoint >>> 10 & 0x3FF | 0xD800)\n codePoint = 0xDC00 | codePoint & 0x3FF\n }\n\n res.push(codePoint)\n i += bytesPerSequence\n }\n\n return decodeCodePointsArray(res)\n}\n\n// Based on http://stackoverflow.com/a/22747272/680742, the browser with\n// the lowest limit is Chrome, with 0x10000 args.\n// We go 1 magnitude less, for safety\nvar MAX_ARGUMENTS_LENGTH = 0x1000\n\nfunction decodeCodePointsArray (codePoints) {\n var len = codePoints.length\n if (len <= MAX_ARGUMENTS_LENGTH) {\n return String.fromCharCode.apply(String, codePoints) // avoid extra slice()\n }\n\n // Decode in chunks to avoid \"call stack size exceeded\".\n var res = ''\n var i = 0\n while (i < len) {\n res += String.fromCharCode.apply(\n String,\n codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)\n )\n }\n return res\n}\n\nfunction asciiSlice (buf, start, end) {\n var ret = ''\n end = Math.min(buf.length, end)\n\n for (var i = start; i < end; ++i) {\n ret += String.fromCharCode(buf[i] & 0x7F)\n }\n return ret\n}\n\nfunction latin1Slice (buf, start, end) {\n var ret = ''\n end = Math.min(buf.length, end)\n\n for (var i = start; i < end; ++i) {\n ret += String.fromCharCode(buf[i])\n }\n return ret\n}\n\nfunction hexSlice (buf, start, end) {\n var len = buf.length\n\n if (!start || start < 0) start = 0\n if (!end || end < 0 || end > len) end = len\n\n var out = ''\n for (var i = start; i < end; ++i) {\n out += toHex(buf[i])\n }\n return out\n}\n\nfunction utf16leSlice (buf, start, end) {\n var bytes = buf.slice(start, end)\n var res = ''\n for (var i = 0; i < bytes.length; i += 2) {\n res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)\n }\n return res\n}\n\nBuffer.prototype.slice = function slice (start, end) {\n var len = this.length\n start = ~~start\n end = end === undefined ? len : ~~end\n\n if (start < 0) {\n start += len\n if (start < 0) start = 0\n } else if (start > len) {\n start = len\n }\n\n if (end < 0) {\n end += len\n if (end < 0) end = 0\n } else if (end > len) {\n end = len\n }\n\n if (end < start) end = start\n\n var newBuf\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n newBuf = this.subarray(start, end)\n newBuf.__proto__ = Buffer.prototype\n } else {\n var sliceLen = end - start\n newBuf = new Buffer(sliceLen, undefined)\n for (var i = 0; i < sliceLen; ++i) {\n newBuf[i] = this[i + start]\n }\n }\n\n return newBuf\n}\n\n/*\n * Need to make sure that buffer isn't trying to write out of bounds.\n */\nfunction checkOffset (offset, ext, length) {\n if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')\n if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')\n}\n\nBuffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var val = this[offset]\n var mul = 1\n var i = 0\n while (++i < byteLength && (mul *= 0x100)) {\n val += this[offset + i] * mul\n }\n\n return val\n}\n\nBuffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) {\n checkOffset(offset, byteLength, this.length)\n }\n\n var val = this[offset + --byteLength]\n var mul = 1\n while (byteLength > 0 && (mul *= 0x100)) {\n val += this[offset + --byteLength] * mul\n }\n\n return val\n}\n\nBuffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 1, this.length)\n return this[offset]\n}\n\nBuffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n return this[offset] | (this[offset + 1] << 8)\n}\n\nBuffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n return (this[offset] << 8) | this[offset + 1]\n}\n\nBuffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return ((this[offset]) |\n (this[offset + 1] << 8) |\n (this[offset + 2] << 16)) +\n (this[offset + 3] * 0x1000000)\n}\n\nBuffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset] * 0x1000000) +\n ((this[offset + 1] << 16) |\n (this[offset + 2] << 8) |\n this[offset + 3])\n}\n\nBuffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var val = this[offset]\n var mul = 1\n var i = 0\n while (++i < byteLength && (mul *= 0x100)) {\n val += this[offset + i] * mul\n }\n mul *= 0x80\n\n if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n return val\n}\n\nBuffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var i = byteLength\n var mul = 1\n var val = this[offset + --i]\n while (i > 0 && (mul *= 0x100)) {\n val += this[offset + --i] * mul\n }\n mul *= 0x80\n\n if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n return val\n}\n\nBuffer.prototype.readInt8 = function readInt8 (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 1, this.length)\n if (!(this[offset] & 0x80)) return (this[offset])\n return ((0xff - this[offset] + 1) * -1)\n}\n\nBuffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n var val = this[offset] | (this[offset + 1] << 8)\n return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n var val = this[offset + 1] | (this[offset] << 8)\n return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset]) |\n (this[offset + 1] << 8) |\n (this[offset + 2] << 16) |\n (this[offset + 3] << 24)\n}\n\nBuffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset] << 24) |\n (this[offset + 1] << 16) |\n (this[offset + 2] << 8) |\n (this[offset + 3])\n}\n\nBuffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n return ieee754.read(this, offset, true, 23, 4)\n}\n\nBuffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n return ieee754.read(this, offset, false, 23, 4)\n}\n\nBuffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 8, this.length)\n return ieee754.read(this, offset, true, 52, 8)\n}\n\nBuffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 8, this.length)\n return ieee754.read(this, offset, false, 52, 8)\n}\n\nfunction checkInt (buf, value, offset, ext, max, min) {\n if (!Buffer.isBuffer(buf)) throw new TypeError('\"buffer\" argument must be a Buffer instance')\n if (value > max || value < min) throw new RangeError('\"value\" argument is out of bounds')\n if (offset + ext > buf.length) throw new RangeError('Index out of range')\n}\n\nBuffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) {\n var maxBytes = Math.pow(2, 8 * byteLength) - 1\n checkInt(this, value, offset, byteLength, maxBytes, 0)\n }\n\n var mul = 1\n var i = 0\n this[offset] = value & 0xFF\n while (++i < byteLength && (mul *= 0x100)) {\n this[offset + i] = (value / mul) & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) {\n var maxBytes = Math.pow(2, 8 * byteLength) - 1\n checkInt(this, value, offset, byteLength, maxBytes, 0)\n }\n\n var i = byteLength - 1\n var mul = 1\n this[offset + i] = value & 0xFF\n while (--i >= 0 && (mul *= 0x100)) {\n this[offset + i] = (value / mul) & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)\n if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)\n this[offset] = (value & 0xff)\n return offset + 1\n}\n\nfunction objectWriteUInt16 (buf, value, offset, littleEndian) {\n if (value < 0) value = 0xffff + value + 1\n for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {\n buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>\n (littleEndian ? i : 1 - i) * 8\n }\n}\n\nBuffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n } else {\n objectWriteUInt16(this, value, offset, true)\n }\n return offset + 2\n}\n\nBuffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 8)\n this[offset + 1] = (value & 0xff)\n } else {\n objectWriteUInt16(this, value, offset, false)\n }\n return offset + 2\n}\n\nfunction objectWriteUInt32 (buf, value, offset, littleEndian) {\n if (value < 0) value = 0xffffffff + value + 1\n for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {\n buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff\n }\n}\n\nBuffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset + 3] = (value >>> 24)\n this[offset + 2] = (value >>> 16)\n this[offset + 1] = (value >>> 8)\n this[offset] = (value & 0xff)\n } else {\n objectWriteUInt32(this, value, offset, true)\n }\n return offset + 4\n}\n\nBuffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 24)\n this[offset + 1] = (value >>> 16)\n this[offset + 2] = (value >>> 8)\n this[offset + 3] = (value & 0xff)\n } else {\n objectWriteUInt32(this, value, offset, false)\n }\n return offset + 4\n}\n\nBuffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) {\n var limit = Math.pow(2, 8 * byteLength - 1)\n\n checkInt(this, value, offset, byteLength, limit - 1, -limit)\n }\n\n var i = 0\n var mul = 1\n var sub = 0\n this[offset] = value & 0xFF\n while (++i < byteLength && (mul *= 0x100)) {\n if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {\n sub = 1\n }\n this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) {\n var limit = Math.pow(2, 8 * byteLength - 1)\n\n checkInt(this, value, offset, byteLength, limit - 1, -limit)\n }\n\n var i = byteLength - 1\n var mul = 1\n var sub = 0\n this[offset + i] = value & 0xFF\n while (--i >= 0 && (mul *= 0x100)) {\n if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {\n sub = 1\n }\n this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)\n if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)\n if (value < 0) value = 0xff + value + 1\n this[offset] = (value & 0xff)\n return offset + 1\n}\n\nBuffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n } else {\n objectWriteUInt16(this, value, offset, true)\n }\n return offset + 2\n}\n\nBuffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 8)\n this[offset + 1] = (value & 0xff)\n } else {\n objectWriteUInt16(this, value, offset, false)\n }\n return offset + 2\n}\n\nBuffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n this[offset + 2] = (value >>> 16)\n this[offset + 3] = (value >>> 24)\n } else {\n objectWriteUInt32(this, value, offset, true)\n }\n return offset + 4\n}\n\nBuffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n if (value < 0) value = 0xffffffff + value + 1\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 24)\n this[offset + 1] = (value >>> 16)\n this[offset + 2] = (value >>> 8)\n this[offset + 3] = (value & 0xff)\n } else {\n objectWriteUInt32(this, value, offset, false)\n }\n return offset + 4\n}\n\nfunction checkIEEE754 (buf, value, offset, ext, max, min) {\n if (offset + ext > buf.length) throw new RangeError('Index out of range')\n if (offset < 0) throw new RangeError('Index out of range')\n}\n\nfunction writeFloat (buf, value, offset, littleEndian, noAssert) {\n if (!noAssert) {\n checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)\n }\n ieee754.write(buf, value, offset, littleEndian, 23, 4)\n return offset + 4\n}\n\nBuffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {\n return writeFloat(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {\n return writeFloat(this, value, offset, false, noAssert)\n}\n\nfunction writeDouble (buf, value, offset, littleEndian, noAssert) {\n if (!noAssert) {\n checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)\n }\n ieee754.write(buf, value, offset, littleEndian, 52, 8)\n return offset + 8\n}\n\nBuffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {\n return writeDouble(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {\n return writeDouble(this, value, offset, false, noAssert)\n}\n\n// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)\nBuffer.prototype.copy = function copy (target, targetStart, start, end) {\n if (!start) start = 0\n if (!end && end !== 0) end = this.length\n if (targetStart >= target.length) targetStart = target.length\n if (!targetStart) targetStart = 0\n if (end > 0 && end < start) end = start\n\n // Copy 0 bytes; we're done\n if (end === start) return 0\n if (target.length === 0 || this.length === 0) return 0\n\n // Fatal error conditions\n if (targetStart < 0) {\n throw new RangeError('targetStart out of bounds')\n }\n if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')\n if (end < 0) throw new RangeError('sourceEnd out of bounds')\n\n // Are we oob?\n if (end > this.length) end = this.length\n if (target.length - targetStart < end - start) {\n end = target.length - targetStart + start\n }\n\n var len = end - start\n var i\n\n if (this === target && start < targetStart && targetStart < end) {\n // descending copy from end\n for (i = len - 1; i >= 0; --i) {\n target[i + targetStart] = this[i + start]\n }\n } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {\n // ascending copy from start\n for (i = 0; i < len; ++i) {\n target[i + targetStart] = this[i + start]\n }\n } else {\n Uint8Array.prototype.set.call(\n target,\n this.subarray(start, start + len),\n targetStart\n )\n }\n\n return len\n}\n\n// Usage:\n// buffer.fill(number[, offset[, end]])\n// buffer.fill(buffer[, offset[, end]])\n// buffer.fill(string[, offset[, end]][, encoding])\nBuffer.prototype.fill = function fill (val, start, end, encoding) {\n // Handle string cases:\n if (typeof val === 'string') {\n if (typeof start === 'string') {\n encoding = start\n start = 0\n end = this.length\n } else if (typeof end === 'string') {\n encoding = end\n end = this.length\n }\n if (val.length === 1) {\n var code = val.charCodeAt(0)\n if (code < 256) {\n val = code\n }\n }\n if (encoding !== undefined && typeof encoding !== 'string') {\n throw new TypeError('encoding must be a string')\n }\n if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {\n throw new TypeError('Unknown encoding: ' + encoding)\n }\n } else if (typeof val === 'number') {\n val = val & 255\n }\n\n // Invalid ranges are not set to a default, so can range check early.\n if (start < 0 || this.length < start || this.length < end) {\n throw new RangeError('Out of range index')\n }\n\n if (end <= start) {\n return this\n }\n\n start = start >>> 0\n end = end === undefined ? this.length : end >>> 0\n\n if (!val) val = 0\n\n var i\n if (typeof val === 'number') {\n for (i = start; i < end; ++i) {\n this[i] = val\n }\n } else {\n var bytes = Buffer.isBuffer(val)\n ? val\n : utf8ToBytes(new Buffer(val, encoding).toString())\n var len = bytes.length\n for (i = 0; i < end - start; ++i) {\n this[i + start] = bytes[i % len]\n }\n }\n\n return this\n}\n\n// HELPER FUNCTIONS\n// ================\n\nvar INVALID_BASE64_RE = /[^+\\/0-9A-Za-z-_]/g\n\nfunction base64clean (str) {\n // Node strips out invalid characters like \\n and \\t from the string, base64-js does not\n str = stringtrim(str).replace(INVALID_BASE64_RE, '')\n // Node converts strings with length < 2 to ''\n if (str.length < 2) return ''\n // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not\n while (str.length % 4 !== 0) {\n str = str + '='\n }\n return str\n}\n\nfunction stringtrim (str) {\n if (str.trim) return str.trim()\n return str.replace(/^\\s+|\\s+$/g, '')\n}\n\nfunction toHex (n) {\n if (n < 16) return '0' + n.toString(16)\n return n.toString(16)\n}\n\nfunction utf8ToBytes (string, units) {\n units = units || Infinity\n var codePoint\n var length = string.length\n var leadSurrogate = null\n var bytes = []\n\n for (var i = 0; i < length; ++i) {\n codePoint = string.charCodeAt(i)\n\n // is surrogate component\n if (codePoint > 0xD7FF && codePoint < 0xE000) {\n // last char was a lead\n if (!leadSurrogate) {\n // no lead yet\n if (codePoint > 0xDBFF) {\n // unexpected trail\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n } else if (i + 1 === length) {\n // unpaired lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n }\n\n // valid lead\n leadSurrogate = codePoint\n\n continue\n }\n\n // 2 leads in a row\n if (codePoint < 0xDC00) {\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n leadSurrogate = codePoint\n continue\n }\n\n // valid surrogate pair\n codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000\n } else if (leadSurrogate) {\n // valid bmp char, but last char was a lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n }\n\n leadSurrogate = null\n\n // encode utf8\n if (codePoint < 0x80) {\n if ((units -= 1) < 0) break\n bytes.push(codePoint)\n } else if (codePoint < 0x800) {\n if ((units -= 2) < 0) break\n bytes.push(\n codePoint >> 0x6 | 0xC0,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x10000) {\n if ((units -= 3) < 0) break\n bytes.push(\n codePoint >> 0xC | 0xE0,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x110000) {\n if ((units -= 4) < 0) break\n bytes.push(\n codePoint >> 0x12 | 0xF0,\n codePoint >> 0xC & 0x3F | 0x80,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else {\n throw new Error('Invalid code point')\n }\n }\n\n return bytes\n}\n\nfunction asciiToBytes (str) {\n var byteArray = []\n for (var i = 0; i < str.length; ++i) {\n // Node's code seems to be doing this and not & 0x7F..\n byteArray.push(str.charCodeAt(i) & 0xFF)\n }\n return byteArray\n}\n\nfunction utf16leToBytes (str, units) {\n var c, hi, lo\n var byteArray = []\n for (var i = 0; i < str.length; ++i) {\n if ((units -= 2) < 0) break\n\n c = str.charCodeAt(i)\n hi = c >> 8\n lo = c % 256\n byteArray.push(lo)\n byteArray.push(hi)\n }\n\n return byteArray\n}\n\nfunction base64ToBytes (str) {\n return base64.toByteArray(base64clean(str))\n}\n\nfunction blitBuffer (src, dst, offset, length) {\n for (var i = 0; i < length; ++i) {\n if ((i + offset >= dst.length) || (i >= src.length)) break\n dst[i + offset] = src[i]\n }\n return i\n}\n\nfunction isnan (val) {\n return val !== val // eslint-disable-line no-self-compare\n}\n","function FilerBuffer (subject, encoding, nonZero) {\r\n\r\n // Automatically turn ArrayBuffer into Uint8Array so that underlying\r\n // Buffer code doesn't just throw away and ignore ArrayBuffer data.\r\n if (subject instanceof ArrayBuffer) {\r\n subject = new Uint8Array(subject);\r\n }\r\n\r\n return new Buffer(subject, encoding, nonZero);\r\n}\r\n\r\n// Inherit prototype from Buffer\r\nFilerBuffer.prototype = Object.create(Buffer.prototype);\r\nFilerBuffer.prototype.constructor = FilerBuffer;\r\n\r\n// Also copy static methods onto FilerBuffer ctor\r\nObject.keys(Buffer).forEach(function (p) {\r\n if (Buffer.hasOwnProperty(p)) {\r\n FilerBuffer[p] = Buffer[p];\r\n }\r\n});\r\n\r\nmodule.exports = FilerBuffer;\r\n","var FILE_SYSTEM_NAME = require('../constants.js').FILE_SYSTEM_NAME;\r\nvar FILE_STORE_NAME = require('../constants.js').FILE_STORE_NAME;\r\nvar IDB_RW = require('../constants.js').IDB_RW;\r\nvar IDB_RO = require('../constants.js').IDB_RO;\r\nvar FilerBuffer = require('../buffer.js');\r\n\r\nvar indexedDB = global.indexedDB ||\r\n global.mozIndexedDB ||\r\n global.webkitIndexedDB ||\r\n global.msIndexedDB;\r\n\r\nfunction IndexedDBContext(db, mode) {\r\n this.db = db;\r\n this.mode = mode;\r\n}\r\n\r\nIndexedDBContext.prototype._getObjectStore = function() {\r\n if(this.objectStore) {\r\n return this.objectStore;\r\n }\r\n\r\n var transaction = this.db.transaction(FILE_STORE_NAME, this.mode);\r\n this.objectStore = transaction.objectStore(FILE_STORE_NAME);\r\n return this.objectStore;\r\n};\r\n\r\nIndexedDBContext.prototype.clear = function(callback) {\r\n try {\r\n var objectStore = this._getObjectStore();\r\n var request = objectStore.clear();\r\n request.onsuccess = function() {\r\n callback();\r\n };\r\n request.onerror = function(event) {\r\n event.preventDefault();\r\n callback(event.error);\r\n };\r\n } catch(err) {\r\n callback(err);\r\n }\r\n};\r\n\r\nIndexedDBContext.prototype._get = function(key, callback) {\r\n try {\r\n var objectStore = this._getObjectStore();\r\n var request = objectStore.get(key);\r\n request.onsuccess = function onsuccess(event) {\r\n var result = event.target.result;\r\n callback(null, result);\r\n };\r\n request.onerror = function(event) {\r\n event.preventDefault();\r\n callback(event.error);\r\n };\r\n } catch(err) {\r\n callback(err);\r\n }\r\n};\r\nIndexedDBContext.prototype.getObject = function(key, callback) {\r\n this._get(key, callback);\r\n};\r\nIndexedDBContext.prototype.getBuffer = function(key, callback) {\r\n this._get(key, function(err, arrayBuffer) {\r\n if(err) {\r\n return callback(err);\r\n }\r\n callback(null, new FilerBuffer(arrayBuffer));\r\n });\r\n};\r\n\r\nIndexedDBContext.prototype._put = function(key, value, callback) {\r\n try {\r\n var objectStore = this._getObjectStore();\r\n var request = objectStore.put(value, key);\r\n request.onsuccess = function onsuccess(event) {\r\n var result = event.target.result;\r\n callback(null, result);\r\n };\r\n request.onerror = function(event) {\r\n event.preventDefault();\r\n callback(event.error);\r\n };\r\n } catch(err) {\r\n callback(err);\r\n }\r\n};\r\nIndexedDBContext.prototype.putObject = function(key, value, callback) {\r\n this._put(key, value, callback);\r\n};\r\nIndexedDBContext.prototype.putBuffer = function(key, uint8BackedBuffer, callback) {\r\n var buf = uint8BackedBuffer.buffer;\r\n this._put(key, buf, callback);\r\n};\r\n\r\nIndexedDBContext.prototype.delete = function(key, callback) {\r\n try {\r\n var objectStore = this._getObjectStore();\r\n var request = objectStore.delete(key);\r\n request.onsuccess = function onsuccess(event) {\r\n var result = event.target.result;\r\n callback(null, result);\r\n };\r\n request.onerror = function(event) {\r\n event.preventDefault();\r\n callback(event.error);\r\n };\r\n } catch(err) {\r\n callback(err);\r\n }\r\n};\r\n\r\n\r\nfunction IndexedDB(name) {\r\n this.name = name || FILE_SYSTEM_NAME;\r\n this.db = null;\r\n}\r\nIndexedDB.isSupported = function() {\r\n return !!indexedDB;\r\n};\r\n\r\nIndexedDB.prototype.open = function(callback) {\r\n var that = this;\r\n\r\n // Bail if we already have a db open\r\n if(that.db) {\r\n return callback();\r\n }\r\n\r\n try {\r\n // NOTE: we're not using versioned databases.\r\n var openRequest = indexedDB.open(that.name);\r\n\r\n // If the db doesn't exist, we'll create it\r\n openRequest.onupgradeneeded = function onupgradeneeded(event) {\r\n var db = event.target.result;\r\n\r\n if(db.objectStoreNames.contains(FILE_STORE_NAME)) {\r\n db.deleteObjectStore(FILE_STORE_NAME);\r\n }\r\n db.createObjectStore(FILE_STORE_NAME);\r\n };\r\n\r\n openRequest.onsuccess = function onsuccess(event) {\r\n that.db = event.target.result;\r\n callback();\r\n };\r\n openRequest.onerror = function onerror(event) {\r\n event.preventDefault();\r\n callback(event.error);\r\n };\r\n } catch(err) {\r\n callback(err);\r\n }\r\n};\r\n\r\nIndexedDB.prototype.getReadOnlyContext = function() {\r\n return new IndexedDBContext(this.db, IDB_RO);\r\n};\r\nIndexedDB.prototype.getReadWriteContext = function() {\r\n return new IndexedDBContext(this.db, IDB_RW);\r\n};\r\n\r\nmodule.exports = IndexedDB;\r\n","var errors = {};\r\n[\r\n /**\r\n * node.js errors - we only use some of these, add as needed.\r\n */\r\n //'-1:UNKNOWN:unknown error',\r\n //'0:OK:success',\r\n //'1:EOF:end of file',\r\n //'2:EADDRINFO:getaddrinfo error',\r\n //'3:EACCES:permission denied',\r\n //'4:EAGAIN:resource temporarily unavailable',\r\n //'5:EADDRINUSE:address already in use',\r\n //'6:EADDRNOTAVAIL:address not available',\r\n //'7:EAFNOSUPPORT:address family not supported',\r\n //'8:EALREADY:connection already in progress',\r\n '9:EBADF:bad file descriptor',\r\n '10:EBUSY:resource busy or locked',\r\n //'11:ECONNABORTED:software caused connection abort',\r\n //'12:ECONNREFUSED:connection refused',\r\n //'13:ECONNRESET:connection reset by peer',\r\n //'14:EDESTADDRREQ:destination address required',\r\n //'15:EFAULT:bad address in system call argument',\r\n //'16:EHOSTUNREACH:host is unreachable',\r\n //'17:EINTR:interrupted system call',\r\n '18:EINVAL:invalid argument',\r\n //'19:EISCONN:socket is already connected',\r\n //'20:EMFILE:too many open files',\r\n //'21:EMSGSIZE:message too long',\r\n //'22:ENETDOWN:network is down',\r\n //'23:ENETUNREACH:network is unreachable',\r\n //'24:ENFILE:file table overflow',\r\n //'25:ENOBUFS:no buffer space available',\r\n //'26:ENOMEM:not enough memory',\r\n '27:ENOTDIR:not a directory',\r\n '28:EISDIR:illegal operation on a directory',\r\n //'29:ENONET:machine is not on the network',\r\n // errno 30 skipped, as per https://github.com/rvagg/node-errno/blob/master/errno.js\r\n //'31:ENOTCONN:socket is not connected',\r\n //'32:ENOTSOCK:socket operation on non-socket',\r\n //'33:ENOTSUP:operation not supported on socket',\r\n '34:ENOENT:no such file or directory',\r\n //'35:ENOSYS:function not implemented',\r\n //'36:EPIPE:broken pipe',\r\n //'37:EPROTO:protocol error',\r\n //'38:EPROTONOSUPPORT:protocol not supported',\r\n //'39:EPROTOTYPE:protocol wrong type for socket',\r\n //'40:ETIMEDOUT:connection timed out',\r\n //'41:ECHARSET:invalid Unicode character',\r\n //'42:EAIFAMNOSUPPORT:address family for hostname not supported',\r\n // errno 43 skipped, as per https://github.com/rvagg/node-errno/blob/master/errno.js\r\n //'44:EAISERVICE:servname not supported for ai_socktype',\r\n //'45:EAISOCKTYPE:ai_socktype not supported',\r\n //'46:ESHUTDOWN:cannot send after transport endpoint shutdown',\r\n '47:EEXIST:file already exists',\r\n //'48:ESRCH:no such process',\r\n //'49:ENAMETOOLONG:name too long',\r\n '50:EPERM:operation not permitted',\r\n '51:ELOOP:too many symbolic links encountered',\r\n //'52:EXDEV:cross-device link not permitted',\r\n '53:ENOTEMPTY:directory not empty',\r\n //'54:ENOSPC:no space left on device',\r\n '55:EIO:i/o error',\r\n //'56:EROFS:read-only file system',\r\n //'57:ENODEV:no such device',\r\n //'58:ESPIPE:invalid seek',\r\n //'59:ECANCELED:operation canceled',\r\n\r\n /**\r\n * Filer specific errors\r\n */\r\n '1000:ENOTMOUNTED:not mounted',\r\n '1001:EFILESYSTEMERROR:missing super node, use \\'FORMAT\\' flag to format filesystem.',\r\n '1002:ENOATTR:attribute does not exist'\r\n\r\n].forEach(function(e) {\r\n e = e.split(':');\r\n var errno = +e[0];\r\n var errName = e[1];\r\n var defaultMessage = e[2];\r\n\r\n function FilerError(msg, path) {\r\n Error.call(this);\r\n\r\n this.name = errName;\r\n this.code = errName;\r\n this.errno = errno;\r\n this.message = msg || defaultMessage;\r\n if(path) {\r\n this.path = path;\r\n }\r\n this.stack = (new Error(this.message)).stack;\r\n }\r\n FilerError.prototype = Object.create(Error.prototype);\r\n FilerError.prototype.constructor = FilerError;\r\n FilerError.prototype.toString = function() {\r\n var pathInfo = this.path ? (', \\'' + this.path + '\\'') : '';\r\n return this.name + ': ' + this.message + pathInfo;\r\n };\r\n\r\n // We expose the error as both Errors.EINVAL and Errors[18]\r\n errors[errName] = errors[errno] = FilerError;\r\n});\r\n\r\nmodule.exports = errors;\r\n","/*\n * base64-arraybuffer\n * https://github.com/niklasvh/base64-arraybuffer\n *\n * Copyright (c) 2012 Niklas von Hertzen\n * Licensed under the MIT license.\n */\n(function(){\n \"use strict\";\n\n var chars = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\n\n // Use a lookup table to find the index.\n var lookup = new Uint8Array(256);\n for (var i = 0; i < chars.length; i++) {\n lookup[chars.charCodeAt(i)] = i;\n }\n\n exports.encode = function(arraybuffer) {\n var bytes = new Uint8Array(arraybuffer),\n i, len = bytes.length, base64 = \"\";\n\n for (i = 0; i < len; i+=3) {\n base64 += chars[bytes[i] >> 2];\n base64 += chars[((bytes[i] & 3) << 4) | (bytes[i + 1] >> 4)];\n base64 += chars[((bytes[i + 1] & 15) << 2) | (bytes[i + 2] >> 6)];\n base64 += chars[bytes[i + 2] & 63];\n }\n\n if ((len % 3) === 2) {\n base64 = base64.substring(0, base64.length - 1) + \"=\";\n } else if (len % 3 === 1) {\n base64 = base64.substring(0, base64.length - 2) + \"==\";\n }\n\n return base64;\n };\n\n exports.decode = function(base64) {\n var bufferLength = base64.length * 0.75,\n len = base64.length, i, p = 0,\n encoded1, encoded2, encoded3, encoded4;\n\n if (base64[base64.length - 1] === \"=\") {\n bufferLength--;\n if (base64[base64.length - 2] === \"=\") {\n bufferLength--;\n }\n }\n\n var arraybuffer = new ArrayBuffer(bufferLength),\n bytes = new Uint8Array(arraybuffer);\n\n for (i = 0; i < len; i+=4) {\n encoded1 = lookup[base64.charCodeAt(i)];\n encoded2 = lookup[base64.charCodeAt(i+1)];\n encoded3 = lookup[base64.charCodeAt(i+2)];\n encoded4 = lookup[base64.charCodeAt(i+3)];\n\n bytes[p++] = (encoded1 << 2) | (encoded2 >> 4);\n bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2);\n bytes[p++] = ((encoded3 & 3) << 6) | (encoded4 & 63);\n }\n\n return arraybuffer;\n };\n})();\n","var FILE_SYSTEM_NAME = require('../constants.js').FILE_SYSTEM_NAME;\r\nvar FILE_STORE_NAME = require('../constants.js').FILE_STORE_NAME;\r\nvar WSQL_VERSION = require('../constants.js').WSQL_VERSION;\r\nvar WSQL_SIZE = require('../constants.js').WSQL_SIZE;\r\nvar WSQL_DESC = require('../constants.js').WSQL_DESC;\r\nvar Errors = require('../errors.js');\r\nvar FilerBuffer = require('../buffer.js');\r\nvar base64ArrayBuffer = require('base64-arraybuffer');\r\n\r\nfunction WebSQLContext(db, isReadOnly) {\r\n var that = this;\r\n this.getTransaction = function(callback) {\r\n if(that.transaction) {\r\n callback(that.transaction);\r\n return;\r\n }\r\n // Either do readTransaction() (read-only) or transaction() (read/write)\r\n db[isReadOnly ? 'readTransaction' : 'transaction'](function(transaction) {\r\n that.transaction = transaction;\r\n callback(transaction);\r\n });\r\n };\r\n}\r\n\r\nWebSQLContext.prototype.clear = function(callback) {\r\n function onError(transaction, error) {\r\n callback(error);\r\n }\r\n function onSuccess() {\r\n callback(null);\r\n }\r\n this.getTransaction(function(transaction) {\r\n transaction.executeSql('DELETE FROM ' + FILE_STORE_NAME + ';',\r\n [], onSuccess, onError);\r\n });\r\n};\r\n\r\nfunction _get(getTransaction, key, callback) {\r\n function onSuccess(transaction, result) {\r\n // If the key isn't found, return null\r\n var value = result.rows.length === 0 ? null : result.rows.item(0).data;\r\n callback(null, value);\r\n }\r\n function onError(transaction, error) {\r\n callback(error);\r\n }\r\n getTransaction(function(transaction) {\r\n transaction.executeSql('SELECT data FROM ' + FILE_STORE_NAME + ' WHERE id = ? LIMIT 1;',\r\n [key], onSuccess, onError);\r\n });\r\n}\r\nWebSQLContext.prototype.getObject = function(key, callback) {\r\n _get(this.getTransaction, key, function(err, result) {\r\n if(err) {\r\n return callback(err);\r\n }\r\n\r\n try {\r\n if(result) {\r\n result = JSON.parse(result);\r\n }\r\n } catch(e) {\r\n return callback(e);\r\n }\r\n\r\n callback(null, result);\r\n });\r\n};\r\nWebSQLContext.prototype.getBuffer = function(key, callback) {\r\n _get(this.getTransaction, key, function(err, result) {\r\n if(err) {\r\n return callback(err);\r\n }\r\n\r\n // Deal with zero-length ArrayBuffers, which will be encoded as ''\r\n if(result || result === '') {\r\n var arrayBuffer = base64ArrayBuffer.decode(result);\r\n result = new FilerBuffer(arrayBuffer);\r\n }\r\n\r\n callback(null, result);\r\n });\r\n};\r\n\r\nfunction _put(getTransaction, key, value, callback) {\r\n function onSuccess() {\r\n callback(null);\r\n }\r\n function onError(transaction, error) {\r\n callback(error);\r\n }\r\n getTransaction(function(transaction) {\r\n transaction.executeSql('INSERT OR REPLACE INTO ' + FILE_STORE_NAME + ' (id, data) VALUES (?, ?);',\r\n [key, value], onSuccess, onError);\r\n });\r\n}\r\nWebSQLContext.prototype.putObject = function(key, value, callback) {\r\n var json = JSON.stringify(value);\r\n _put(this.getTransaction, key, json, callback);\r\n};\r\nWebSQLContext.prototype.putBuffer = function(key, uint8BackedBuffer, callback) {\r\n var base64 = base64ArrayBuffer.encode(uint8BackedBuffer.buffer);\r\n _put(this.getTransaction, key, base64, callback);\r\n};\r\n\r\nWebSQLContext.prototype.delete = function(key, callback) {\r\n function onSuccess() {\r\n callback(null);\r\n }\r\n function onError(transaction, error) {\r\n callback(error);\r\n }\r\n this.getTransaction(function(transaction) {\r\n transaction.executeSql('DELETE FROM ' + FILE_STORE_NAME + ' WHERE id = ?;',\r\n [key], onSuccess, onError);\r\n });\r\n};\r\n\r\n\r\nfunction WebSQL(name) {\r\n this.name = name || FILE_SYSTEM_NAME;\r\n this.db = null;\r\n}\r\nWebSQL.isSupported = function() {\r\n return !!global.openDatabase;\r\n};\r\n\r\nWebSQL.prototype.open = function(callback) {\r\n var that = this;\r\n\r\n // Bail if we already have a db open\r\n if(that.db) {\r\n return callback();\r\n }\r\n\r\n var db = global.openDatabase(that.name, WSQL_VERSION, WSQL_DESC, WSQL_SIZE);\r\n if(!db) {\r\n callback('[WebSQL] Unable to open database.');\r\n return;\r\n }\r\n\r\n function onError(transaction, error) {\r\n if (error.code === 5) {\r\n callback(new Errors.EINVAL('WebSQL cannot be accessed. If private browsing is enabled, disable it.'));\r\n }\r\n callback(error);\r\n }\r\n function onSuccess() {\r\n that.db = db;\r\n callback();\r\n }\r\n\r\n // Create the table and index we'll need to store the fs data.\r\n db.transaction(function(transaction) {\r\n function createIndex(transaction) {\r\n transaction.executeSql('CREATE INDEX IF NOT EXISTS idx_' + FILE_STORE_NAME + '_id' +\r\n ' on ' + FILE_STORE_NAME + ' (id);',\r\n [], onSuccess, onError);\r\n }\r\n transaction.executeSql('CREATE TABLE IF NOT EXISTS ' + FILE_STORE_NAME + ' (id unique, data TEXT);',\r\n [], createIndex, onError);\r\n });\r\n};\r\nWebSQL.prototype.getReadOnlyContext = function() {\r\n return new WebSQLContext(this.db, true);\r\n};\r\nWebSQL.prototype.getReadWriteContext = function() {\r\n return new WebSQLContext(this.db, false);\r\n};\r\n\r\nmodule.exports = WebSQL;\r\n","// shim for using process in browser\nvar process = module.exports = {};\n\n// cached from whatever global is present so that test runners that stub it\n// don't break things. But we need to wrap it in a try catch in case it is\n// wrapped in strict mode code which doesn't define any globals. It's inside a\n// function because try/catches deoptimize in certain engines.\n\nvar cachedSetTimeout;\nvar cachedClearTimeout;\n\nfunction defaultSetTimout() {\n throw new Error('setTimeout has not been defined');\n}\nfunction defaultClearTimeout () {\n throw new Error('clearTimeout has not been defined');\n}\n(function () {\n try {\n if (typeof setTimeout === 'function') {\n cachedSetTimeout = setTimeout;\n } else {\n cachedSetTimeout = defaultSetTimout;\n }\n } catch (e) {\n cachedSetTimeout = defaultSetTimout;\n }\n try {\n if (typeof clearTimeout === 'function') {\n cachedClearTimeout = clearTimeout;\n } else {\n cachedClearTimeout = defaultClearTimeout;\n }\n } catch (e) {\n cachedClearTimeout = defaultClearTimeout;\n }\n} ())\nfunction runTimeout(fun) {\n if (cachedSetTimeout === setTimeout) {\n //normal enviroments in sane situations\n return setTimeout(fun, 0);\n }\n // if setTimeout wasn't available but was latter defined\n if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {\n cachedSetTimeout = setTimeout;\n return setTimeout(fun, 0);\n }\n try {\n // when when somebody has screwed with setTimeout but no I.E. maddness\n return cachedSetTimeout(fun, 0);\n } catch(e){\n try {\n // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally\n return cachedSetTimeout.call(null, fun, 0);\n } catch(e){\n // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error\n return cachedSetTimeout.call(this, fun, 0);\n }\n }\n\n\n}\nfunction runClearTimeout(marker) {\n if (cachedClearTimeout === clearTimeout) {\n //normal enviroments in sane situations\n return clearTimeout(marker);\n }\n // if clearTimeout wasn't available but was latter defined\n if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {\n cachedClearTimeout = clearTimeout;\n return clearTimeout(marker);\n }\n try {\n // when when somebody has screwed with setTimeout but no I.E. maddness\n return cachedClearTimeout(marker);\n } catch (e){\n try {\n // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally\n return cachedClearTimeout.call(null, marker);\n } catch (e){\n // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.\n // Some versions of I.E. have different rules for clearTimeout vs setTimeout\n return cachedClearTimeout.call(this, marker);\n }\n }\n\n\n\n}\nvar queue = [];\nvar draining = false;\nvar currentQueue;\nvar queueIndex = -1;\n\nfunction cleanUpNextTick() {\n if (!draining || !currentQueue) {\n return;\n }\n draining = false;\n if (currentQueue.length) {\n queue = currentQueue.concat(queue);\n } else {\n queueIndex = -1;\n }\n if (queue.length) {\n drainQueue();\n }\n}\n\nfunction drainQueue() {\n if (draining) {\n return;\n }\n var timeout = runTimeout(cleanUpNextTick);\n draining = true;\n\n var len = queue.length;\n while(len) {\n currentQueue = queue;\n queue = [];\n while (++queueIndex < len) {\n if (currentQueue) {\n currentQueue[queueIndex].run();\n }\n }\n queueIndex = -1;\n len = queue.length;\n }\n currentQueue = null;\n draining = false;\n runClearTimeout(timeout);\n}\n\nprocess.nextTick = function (fun) {\n var args = new Array(arguments.length - 1);\n if (arguments.length > 1) {\n for (var i = 1; i < arguments.length; i++) {\n args[i - 1] = arguments[i];\n }\n }\n queue.push(new Item(fun, args));\n if (queue.length === 1 && !draining) {\n runTimeout(drainQueue);\n }\n};\n\n// v8 likes predictible objects\nfunction Item(fun, array) {\n this.fun = fun;\n this.array = array;\n}\nItem.prototype.run = function () {\n this.fun.apply(null, this.array);\n};\nprocess.title = 'browser';\nprocess.browser = true;\nprocess.env = {};\nprocess.argv = [];\nprocess.version = ''; // empty string to avoid regexp issues\nprocess.versions = {};\n\nfunction noop() {}\n\nprocess.on = noop;\nprocess.addListener = noop;\nprocess.once = noop;\nprocess.off = noop;\nprocess.removeListener = noop;\nprocess.removeAllListeners = noop;\nprocess.emit = noop;\nprocess.prependListener = noop;\nprocess.prependOnceListener = noop;\n\nprocess.listeners = function (name) { return [] }\n\nprocess.binding = function (name) {\n throw new Error('process.binding is not supported');\n};\n\nprocess.cwd = function () { return '/' };\nprocess.chdir = function (dir) {\n throw new Error('process.chdir is not supported');\n};\nprocess.umask = function() { return 0; };\n","/*global setImmediate: false, setTimeout: false, console: false */\r\n\r\n/**\r\n * async.js shim, based on https://raw.github.com/caolan/async/master/lib/async.js Feb 18, 2014\r\n * Used under MIT - https://github.com/caolan/async/blob/master/LICENSE\r\n */\r\n\r\n(function () {\r\n\r\n var async = {};\r\n\r\n // async.js functions used in Filer\r\n\r\n //// nextTick implementation with browser-compatible fallback ////\r\n if (typeof process === 'undefined' || !(process.nextTick)) {\r\n if (typeof setImmediate === 'function') {\r\n async.nextTick = function (fn) {\r\n // not a direct alias for IE10 compatibility\r\n setImmediate(fn);\r\n };\r\n async.setImmediate = async.nextTick;\r\n }\r\n else {\r\n async.nextTick = function (fn) {\r\n setTimeout(fn, 0);\r\n };\r\n async.setImmediate = async.nextTick;\r\n }\r\n }\r\n else {\r\n async.nextTick = process.nextTick;\r\n if (typeof setImmediate !== 'undefined') {\r\n async.setImmediate = function (fn) {\r\n // not a direct alias for IE10 compatibility\r\n setImmediate(fn);\r\n };\r\n }\r\n else {\r\n async.setImmediate = async.nextTick;\r\n }\r\n }\r\n\r\n async.eachSeries = function (arr, iterator, callback) {\r\n callback = callback || function () {};\r\n if (!arr.length) {\r\n return callback();\r\n }\r\n var completed = 0;\r\n var iterate = function () {\r\n iterator(arr[completed], function (err) {\r\n if (err) {\r\n callback(err);\r\n callback = function () {};\r\n }\r\n else {\r\n completed += 1;\r\n if (completed >= arr.length) {\r\n callback();\r\n }\r\n else {\r\n iterate();\r\n }\r\n }\r\n });\r\n };\r\n iterate();\r\n };\r\n async.forEachSeries = async.eachSeries;\r\n\r\n // AMD / RequireJS\r\n if (typeof define !== 'undefined' && define.amd) {\r\n define([], function () {\r\n return async;\r\n });\r\n }\r\n // Node.js\r\n else if (typeof module !== 'undefined' && module.exports) {\r\n module.exports = async;\r\n }\r\n // included directly via <script> tag\r\n else {\r\n root.async = async;\r\n }\r\n\r\n}());\r\n","var FILE_SYSTEM_NAME = require('../constants.js').FILE_SYSTEM_NAME;\r\n// NOTE: prefer setImmediate to nextTick for proper recursion yielding.\r\n// see https://github.com/js-platform/filer/pull/24\r\nvar asyncCallback = require('../../lib/async.js').setImmediate;\r\n\r\n/**\r\n * Make shared in-memory DBs possible when using the same name.\r\n */\r\nvar createDB = (function() {\r\n var pool = {};\r\n return function getOrCreate(name) {\r\n if(!pool.hasOwnProperty(name)) {\r\n pool[name] = {};\r\n }\r\n return pool[name];\r\n };\r\n}());\r\n\r\nfunction MemoryContext(db, readOnly) {\r\n this.readOnly = readOnly;\r\n this.objectStore = db;\r\n}\r\n\r\nMemoryContext.prototype.clear = function(callback) {\r\n if(this.readOnly) {\r\n asyncCallback(function() {\r\n callback('[MemoryContext] Error: write operation on read only context');\r\n });\r\n return;\r\n }\r\n var objectStore = this.objectStore;\r\n Object.keys(objectStore).forEach(function(key){\r\n delete objectStore[key];\r\n });\r\n asyncCallback(callback);\r\n};\r\n\r\n// Memory context doesn't care about differences between Object and Buffer\r\nMemoryContext.prototype.getObject =\r\nMemoryContext.prototype.getBuffer =\r\nfunction(key, callback) {\r\n var that = this;\r\n asyncCallback(function() {\r\n callback(null, that.objectStore[key]);\r\n });\r\n};\r\nMemoryContext.prototype.putObject =\r\nMemoryContext.prototype.putBuffer =\r\nfunction(key, value, callback) {\r\n if(this.readOnly) {\r\n asyncCallback(function() {\r\n callback('[MemoryContext] Error: write operation on read only context');\r\n });\r\n return;\r\n }\r\n this.objectStore[key] = value;\r\n asyncCallback(callback);\r\n};\r\n\r\nMemoryContext.prototype.delete = function(key, callback) {\r\n if(this.readOnly) {\r\n asyncCallback(function() {\r\n callback('[MemoryContext] Error: write operation on read only context');\r\n });\r\n return;\r\n }\r\n delete this.objectStore[key];\r\n asyncCallback(callback);\r\n};\r\n\r\n\r\nfunction Memory(name) {\r\n this.name = name || FILE_SYSTEM_NAME;\r\n}\r\nMemory.isSupported = function() {\r\n return true;\r\n};\r\n\r\nMemory.prototype.open = function(callback) {\r\n this.db = createDB(this.name);\r\n asyncCallback(callback);\r\n};\r\nMemory.prototype.getReadOnlyContext = function() {\r\n return new MemoryContext(this.db, true);\r\n};\r\nMemory.prototype.getReadWriteContext = function() {\r\n return new MemoryContext(this.db, false);\r\n};\r\n\r\nmodule.exports = Memory;\r\n","var IndexedDB = require('./indexeddb.js');\r\nvar WebSQL = require('./websql.js');\r\nvar Memory = require('./memory.js');\r\n\r\nmodule.exports = {\r\n IndexedDB: IndexedDB,\r\n WebSQL: WebSQL,\r\n Memory: Memory,\r\n\r\n /**\r\n * Convenience Provider references\r\n */\r\n\r\n // The default provider to use when none is specified\r\n Default: IndexedDB,\r\n\r\n // The Fallback provider does automatic fallback checks\r\n Fallback: (function() {\r\n if(IndexedDB.isSupported()) {\r\n return IndexedDB;\r\n }\r\n\r\n if(WebSQL.isSupported()) {\r\n return WebSQL;\r\n }\r\n\r\n function NotSupported() {\r\n throw '[Filer Error] Your browser doesn\\'t support IndexedDB or WebSQL.';\r\n }\r\n NotSupported.isSupported = function() {\r\n return false;\r\n };\r\n return NotSupported;\r\n }())\r\n};\r\n","var defaults = require('../constants.js').ENVIRONMENT;\r\n\r\nmodule.exports = function Environment(env) {\r\n env = env || {};\r\n env.TMP = env.TMP || defaults.TMP;\r\n env.PATH = env.PATH || defaults.PATH;\r\n\r\n this.get = function(name) {\r\n return env[name];\r\n };\r\n\r\n this.set = function(name, value) {\r\n env[name] = value;\r\n };\r\n};\r\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n// resolves . and .. elements in a path array with directory names there\n// must be no slashes, empty elements, or device names (c:\\) in the array\n// (so also no leading and trailing slashes - it does not distinguish\n// relative and absolute paths)\nfunction normalizeArray(parts, allowAboveRoot) {\n // if the path tries to go above the root, `up` ends up > 0\n var up = 0;\n for (var i = parts.length - 1; i >= 0; i--) {\n var last = parts[i];\n if (last === '.') {\n parts.splice(i, 1);\n } else if (last === '..') {\n parts.splice(i, 1);\n up++;\n } else if (up) {\n parts.splice(i, 1);\n up--;\n }\n }\n\n // if the path is allowed to go above the root, restore leading ..s\n if (allowAboveRoot) {\n for (; up--; up) {\n parts.unshift('..');\n }\n }\n\n return parts;\n}\n\n// Split a filename into [root, dir, basename, ext], unix version\n// 'root' is just a slash, or nothing.\nvar splitPathRe =\n /^(\\/?|)([\\s\\S]*?)((?:\\.{1,2}|[^\\/]+?|)(\\.[^.\\/]*|))(?:[\\/]*)$/;\nvar splitPath = function(filename) {\n return splitPathRe.exec(filename).slice(1);\n};\n\n// path.resolve([from ...], to)\n// posix version\nexports.resolve = function() {\n var resolvedPath = '',\n resolvedAbsolute = false;\n\n for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {\n var path = (i >= 0) ? arguments[i] : process.cwd();\n\n // Skip empty and invalid entries\n if (typeof path !== 'string') {\n throw new TypeError('Arguments to path.resolve must be strings');\n } else if (!path) {\n continue;\n }\n\n resolvedPath = path + '/' + resolvedPath;\n resolvedAbsolute = path.charAt(0) === '/';\n }\n\n // At this point the path should be resolved to a full absolute path, but\n // handle relative paths to be safe (might happen when process.cwd() fails)\n\n // Normalize the path\n resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {\n return !!p;\n }), !resolvedAbsolute).join('/');\n\n return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';\n};\n\n// path.normalize(path)\n// posix version\nexports.normalize = function(path) {\n var isAbsolute = exports.isAbsolute(path),\n trailingSlash = substr(path, -1) === '/';\n\n // Normalize the path\n path = normalizeArray(filter(path.split('/'), function(p) {\n return !!p;\n }), !isAbsolute).join('/');\n\n if (!path && !isAbsolute) {\n path = '.';\n }\n if (path && trailingSlash) {\n path += '/';\n }\n\n return (isAbsolute ? '/' : '') + path;\n};\n\n// posix version\nexports.isAbsolute = function(path) {\n return path.charAt(0) === '/';\n};\n\n// posix version\nexports.join = function() {\n var paths = Array.prototype.slice.call(arguments, 0);\n return exports.normalize(filter(paths, function(p, index) {\n if (typeof p !== 'string') {\n throw new TypeError('Arguments to path.join must be strings');\n }\n return p;\n }).join('/'));\n};\n\n\n// path.relative(from, to)\n// posix version\nexports.relative = function(from, to) {\n from = exports.resolve(from).substr(1);\n to = exports.resolve(to).substr(1);\n\n function trim(arr) {\n var start = 0;\n for (; start < arr.length; start++) {\n if (arr[start] !== '') break;\n }\n\n var end = arr.length - 1;\n for (; end >= 0; end--) {\n if (arr[end] !== '') break;\n }\n\n if (start > end) return [];\n return arr.slice(start, end - start + 1);\n }\n\n var fromParts = trim(from.split('/'));\n var toParts = trim(to.split('/'));\n\n var length = Math.min(fromParts.length, toParts.length);\n var samePartsLength = length;\n for (var i = 0; i < length; i++) {\n if (fromParts[i] !== toParts[i]) {\n samePartsLength = i;\n break;\n }\n }\n\n var outputParts = [];\n for (var i = samePartsLength; i < fromParts.length; i++) {\n outputParts.push('..');\n }\n\n outputParts = outputParts.concat(toParts.slice(samePartsLength));\n\n return outputParts.join('/');\n};\n\nexports.sep = '/';\nexports.delimiter = ':';\n\nexports.dirname = function(path) {\n var result = splitPath(path),\n root = result[0],\n dir = result[1];\n\n if (!root && !dir) {\n // No dirname whatsoever\n return '.';\n }\n\n if (dir) {\n // It has a dirname, strip trailing slash\n dir = dir.substr(0, dir.length - 1);\n }\n\n return root + dir;\n};\n\n\nexports.basename = function(path, ext) {\n var f = splitPath(path)[2];\n // TODO: make this comparison case-insensitive on windows?\n if (ext && f.substr(-1 * ext.length) === ext) {\n f = f.substr(0, f.length - ext.length);\n }\n return f;\n};\n\n\nexports.extname = function(path) {\n return splitPath(path)[3];\n};\n\nfunction filter (xs, f) {\n if (xs.filter) return xs.filter(f);\n var res = [];\n for (var i = 0; i < xs.length; i++) {\n if (f(xs[i], i, xs)) res.push(xs[i]);\n }\n return res;\n}\n\n// String.prototype.substr - negative index don't work in IE8\nvar substr = 'ab'.substr(-1) === 'b'\n ? function (str, start, len) { return str.substr(start, len) }\n : function (str, start, len) {\n if (start < 0) start = str.length + start;\n return str.substr(start, len);\n }\n;\n","module.exports = function (xs, fn) {\n var res = [];\n for (var i = 0; i < xs.length; i++) {\n var x = fn(xs[i], i);\n if (isArray(x)) res.push.apply(res, x);\n else res.push(x);\n }\n return res;\n};\n\nvar isArray = Array.isArray || function (xs) {\n return Object.prototype.toString.call(xs) === '[object Array]';\n};\n","'use strict';\nmodule.exports = balanced;\nfunction balanced(a, b, str) {\n if (a instanceof RegExp) a = maybeMatch(a, str);\n if (b instanceof RegExp) b = maybeMatch(b, str);\n\n var r = range(a, b, str);\n\n return r && {\n start: r[0],\n end: r[1],\n pre: str.slice(0, r[0]),\n body: str.slice(r[0] + a.length, r[1]),\n post: str.slice(r[1] + b.length)\n };\n}\n\nfunction maybeMatch(reg, str) {\n var m = str.match(reg);\n return m ? m[0] : null;\n}\n\nbalanced.range = range;\nfunction range(a, b, str) {\n var begs, beg, left, right, result;\n var ai = str.indexOf(a);\n var bi = str.indexOf(b, ai + 1);\n var i = ai;\n\n if (ai >= 0 && bi > 0) {\n begs = [];\n left = str.length;\n\n while (i >= 0 && !result) {\n if (i == ai) {\n begs.push(i);\n ai = str.indexOf(a, i + 1);\n } else if (begs.length == 1) {\n result = [ begs.pop(), bi ];\n } else {\n beg = begs.pop();\n if (beg < left) {\n left = beg;\n right = bi;\n }\n\n bi = str.indexOf(b, i + 1);\n }\n\n i = ai < bi && ai >= 0 ? ai : bi;\n }\n\n if (begs.length) {\n result = [ left, right ];\n }\n }\n\n return result;\n}\n","var concatMap = require('concat-map');\nvar balanced = require('balanced-match');\n\nmodule.exports = expandTop;\n\nvar escSlash = '\\0SLASH'+Math.random()+'\\0';\nvar escOpen = '\\0OPEN'+Math.random()+'\\0';\nvar escClose = '\\0CLOSE'+Math.random()+'\\0';\nvar escComma = '\\0COMMA'+Math.random()+'\\0';\nvar escPeriod = '\\0PERIOD'+Math.random()+'\\0';\n\nfunction numeric(str) {\n return parseInt(str, 10) == str\n ? parseInt(str, 10)\n : str.charCodeAt(0);\n}\n\nfunction escapeBraces(str) {\n return str.split('\\\\\\\\').join(escSlash)\n .split('\\\\{').join(escOpen)\n .split('\\\\}').join(escClose)\n .split('\\\\,').join(escComma)\n .split('\\\\.').join(escPeriod);\n}\n\nfunction unescapeBraces(str) {\n return str.split(escSlash).join('\\\\')\n .split(escOpen).join('{')\n .split(escClose).join('}')\n .split(escComma).join(',')\n .split(escPeriod).join('.');\n}\n\n\n// Basically just str.split(\",\"), but handling cases\n// where we have nested braced sections, which should be\n// treated as individual members, like {a,{b,c},d}\nfunction parseCommaParts(str) {\n if (!str)\n return [''];\n\n var parts = [];\n var m = balanced('{', '}', str);\n\n if (!m)\n return str.split(',');\n\n var pre = m.pre;\n var body = m.body;\n var post = m.post;\n var p = pre.split(',');\n\n p[p.length-1] += '{' + body + '}';\n var postParts = parseCommaParts(post);\n if (post.length) {\n p[p.length-1] += postParts.shift();\n p.push.apply(p, postParts);\n }\n\n parts.push.apply(parts, p);\n\n return parts;\n}\n\nfunction expandTop(str) {\n if (!str)\n return [];\n\n // I don't know why Bash 4.3 does this, but it does.\n // Anything starting with {} will have the first two bytes preserved\n // but *only* at the top level, so {},a}b will not expand to anything,\n // but a{},b}c will be expanded to [a}c,abc].\n // One could argue that this is a bug in Bash, but since the goal of\n // this module is to match Bash's rules, we escape a leading {}\n if (str.substr(0, 2) === '{}') {\n str = '\\\\{\\\\}' + str.substr(2);\n }\n\n return expand(escapeBraces(str), true).map(unescapeBraces);\n}\n\nfunction identity(e) {\n return e;\n}\n\nfunction embrace(str) {\n return '{' + str + '}';\n}\nfunction isPadded(el) {\n return /^-?0\\d/.test(el);\n}\n\nfunction lte(i, y) {\n return i <= y;\n}\nfunction gte(i, y) {\n return i >= y;\n}\n\nfunction expand(str, isTop) {\n var expansions = [];\n\n var m = balanced('{', '}', str);\n if (!m || /\\$$/.test(m.pre)) return [str];\n\n var isNumericSequence = /^-?\\d+\\.\\.-?\\d+(?:\\.\\.-?\\d+)?$/.test(m.body);\n var isAlphaSequence = /^[a-zA-Z]\\.\\.[a-zA-Z](?:\\.\\.-?\\d+)?$/.test(m.body);\n var isSequence = isNumericSequence || isAlphaSequence;\n var isOptions = m.body.indexOf(',') >= 0;\n if (!isSequence && !isOptions) {\n // {a},b}\n if (m.post.match(/,.*\\}/)) {\n str = m.pre + '{' + m.body + escClose + m.post;\n return expand(str);\n }\n return [str];\n }\n\n var n;\n if (isSequence) {\n n = m.body.split(/\\.\\./);\n } else {\n n = parseCommaParts(m.body);\n if (n.length === 1) {\n // x{{a,b}}y ==> x{a}y x{b}y\n n = expand(n[0], false).map(embrace);\n if (n.length === 1) {\n var post = m.post.length\n ? expand(m.post, false)\n : [''];\n return post.map(function(p) {\n return m.pre + n[0] + p;\n });\n }\n }\n }\n\n // at this point, n is the parts, and we know it's not a comma set\n // with a single entry.\n\n // no need to expand pre, since it is guaranteed to be free of brace-sets\n var pre = m.pre;\n var post = m.post.length\n ? expand(m.post, false)\n : [''];\n\n var N;\n\n if (isSequence) {\n var x = numeric(n[0]);\n var y = numeric(n[1]);\n var width = Math.max(n[0].length, n[1].length)\n var incr = n.length == 3\n ? Math.abs(numeric(n[2]))\n : 1;\n var test = lte;\n var reverse = y < x;\n if (reverse) {\n incr *= -1;\n test = gte;\n }\n var pad = n.some(isPadded);\n\n N = [];\n\n for (var i = x; test(i, y); i += incr) {\n var c;\n if (isAlphaSequence) {\n c = String.fromCharCode(i);\n if (c === '\\\\')\n c = '';\n } else {\n c = String(i);\n if (pad) {\n var need = width - c.length;\n if (need > 0) {\n var z = new Array(need + 1).join('0');\n if (i < 0)\n c = '-' + z + c.slice(1);\n else\n c = z + c;\n }\n }\n }\n N.push(c);\n }\n } else {\n N = concatMap(n, function(el) { return expand(el, false) });\n }\n\n for (var j = 0; j < N.length; j++) {\n for (var k = 0; k < post.length; k++) {\n var expansion = pre + N[j] + post[k];\n if (!isTop || isSequence || expansion)\n expansions.push(expansion);\n }\n }\n\n return expansions;\n}\n\n","module.exports = minimatch\nminimatch.Minimatch = Minimatch\n\nvar path = { sep: '/' }\ntry {\n path = require('path')\n} catch (er) {}\n\nvar GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {}\nvar expand = require('brace-expansion')\n\nvar plTypes = {\n '!': { open: '(?:(?!(?:', close: '))[^/]*?)'},\n '?': { open: '(?:', close: ')?' },\n '+': { open: '(?:', close: ')+' },\n '*': { open: '(?:', close: ')*' },\n '@': { open: '(?:', close: ')' }\n}\n\n// any single thing other than /\n// don't need to escape / when using new RegExp()\nvar qmark = '[^/]'\n\n// * => any number of characters\nvar star = qmark + '*?'\n\n// ** when dots are allowed. Anything goes, except .. and .\n// not (^ or / followed by one or two dots followed by $ or /),\n// followed by anything, any number of times.\nvar twoStarDot = '(?:(?!(?:\\\\\\/|^)(?:\\\\.{1,2})($|\\\\\\/)).)*?'\n\n// not a ^ or / followed by a dot,\n// followed by anything, any number of times.\nvar twoStarNoDot = '(?:(?!(?:\\\\\\/|^)\\\\.).)*?'\n\n// characters that need to be escaped in RegExp.\nvar reSpecials = charSet('().*{}+?[]^$\\\\!')\n\n// \"abc\" -> { a:true, b:true, c:true }\nfunction charSet (s) {\n return s.split('').reduce(function (set, c) {\n set[c] = true\n return set\n }, {})\n}\n\n// normalizes slashes.\nvar slashSplit = /\\/+/\n\nminimatch.filter = filter\nfunction filter (pattern, options) {\n options = options || {}\n return function (p, i, list) {\n return minimatch(p, pattern, options)\n }\n}\n\nfunction ext (a, b) {\n a = a || {}\n b = b || {}\n var t = {}\n Object.keys(b).forEach(function (k) {\n t[k] = b[k]\n })\n Object.keys(a).forEach(function (k) {\n t[k] = a[k]\n })\n return t\n}\n\nminimatch.defaults = function (def) {\n if (!def || !Object.keys(def).length) return minimatch\n\n var orig = minimatch\n\n var m = function minimatch (p, pattern, options) {\n return orig.minimatch(p, pattern, ext(def, options))\n }\n\n m.Minimatch = function Minimatch (pattern, options) {\n return new orig.Minimatch(pattern, ext(def, options))\n }\n\n return m\n}\n\nMinimatch.defaults = function (def) {\n if (!def || !Object.keys(def).length) return Minimatch\n return minimatch.defaults(def).Minimatch\n}\n\nfunction minimatch (p, pattern, options) {\n if (typeof pattern !== 'string') {\n throw new TypeError('glob pattern string required')\n }\n\n if (!options) options = {}\n\n // shortcut: comments match nothing.\n if (!options.nocomment && pattern.charAt(0) === '#') {\n return false\n }\n\n // \"\" only matches \"\"\n if (pattern.trim() === '') return p === ''\n\n return new Minimatch(pattern, options).match(p)\n}\n\nfunction Minimatch (pattern, options) {\n if (!(this instanceof Minimatch)) {\n return new Minimatch(pattern, options)\n }\n\n if (typeof pattern !== 'string') {\n throw new TypeError('glob pattern string required')\n }\n\n if (!options) options = {}\n pattern = pattern.trim()\n\n // windows support: need to use /, not \\\n if (path.sep !== '/') {\n pattern = pattern.split(path.sep).join('/')\n }\n\n this.options = options\n this.set = []\n this.pattern = pattern\n this.regexp = null\n this.negate = false\n this.comment = false\n this.empty = false\n\n // make the set of regexps etc.\n this.make()\n}\n\nMinimatch.prototype.debug = function () {}\n\nMinimatch.prototype.make = make\nfunction make () {\n // don't do it more than once.\n if (this._made) return\n\n var pattern = this.pattern\n var options = this.options\n\n // empty patterns and comments match nothing.\n if (!options.nocomment && pattern.charAt(0) === '#') {\n this.comment = true\n return\n }\n if (!pattern) {\n this.empty = true\n return\n }\n\n // step 1: figure out negation, etc.\n this.parseNegate()\n\n // step 2: expand braces\n var set = this.globSet = this.braceExpand()\n\n if (options.debug) this.debug = console.error\n\n this.debug(this.pattern, set)\n\n // step 3: now we have a set, so turn each one into a series of path-portion\n // matching patterns.\n // These will be regexps, except in the case of \"**\", which is\n // set to the GLOBSTAR object for globstar behavior,\n // and will not contain any / characters\n set = this.globParts = set.map(function (s) {\n return s.split(slashSplit)\n })\n\n this.debug(this.pattern, set)\n\n // glob --> regexps\n set = set.map(function (s, si, set) {\n return s.map(this.parse, this)\n }, this)\n\n this.debug(this.pattern, set)\n\n // filter out everything that didn't compile properly.\n set = set.filter(function (s) {\n return s.indexOf(false) === -1\n })\n\n this.debug(this.pattern, set)\n\n this.set = set\n}\n\nMinimatch.prototype.parseNegate = parseNegate\nfunction parseNegate () {\n var pattern = this.pattern\n var negate = false\n var options = this.options\n var negateOffset = 0\n\n if (options.nonegate) return\n\n for (var i = 0, l = pattern.length\n ; i < l && pattern.charAt(i) === '!'\n ; i++) {\n negate = !negate\n negateOffset++\n }\n\n if (negateOffset) this.pattern = pattern.substr(negateOffset)\n this.negate = negate\n}\n\n// Brace expansion:\n// a{b,c}d -> abd acd\n// a{b,}c -> abc ac\n// a{0..3}d -> a0d a1d a2d a3d\n// a{b,c{d,e}f}g -> abg acdfg acefg\n// a{b,c}d{e,f}g -> abdeg acdeg abdeg abdfg\n//\n// Invalid sets are not expanded.\n// a{2..}b -> a{2..}b\n// a{b}c -> a{b}c\nminimatch.braceExpand = function (pattern, options) {\n return braceExpand(pattern, options)\n}\n\nMinimatch.prototype.braceExpand = braceExpand\n\nfunction braceExpand (pattern, options) {\n if (!options) {\n if (this instanceof Minimatch) {\n options = this.options\n } else {\n options = {}\n }\n }\n\n pattern = typeof pattern === 'undefined'\n ? this.pattern : pattern\n\n if (typeof pattern === 'undefined') {\n throw new TypeError('undefined pattern')\n }\n\n if (options.nobrace ||\n !pattern.match(/\\{.*\\}/)) {\n // shortcut. no need to expand.\n return [pattern]\n }\n\n return expand(pattern)\n}\n\n// parse a component of the expanded set.\n// At this point, no pattern may contain \"/\" in it\n// so we're going to return a 2d array, where each entry is the full\n// pattern, split on '/', and then turned into a regular expression.\n// A regexp is made at the end which joins each array with an\n// escaped /, and another full one which joins each regexp with |.\n//\n// Following the lead of Bash 4.1, note that \"**\" only has special meaning\n// when it is the *only* thing in a path portion. Otherwise, any series\n// of * is equivalent to a single *. Globstar behavior is enabled by\n// default, and can be disabled by setting options.noglobstar.\nMinimatch.prototype.parse = parse\nvar SUBPARSE = {}\nfunction parse (pattern, isSub) {\n if (pattern.length > 1024 * 64) {\n throw new TypeError('pattern is too long')\n }\n\n var options = this.options\n\n // shortcuts\n if (!options.noglobstar && pattern === '**') return GLOBSTAR\n if (pattern === '') return ''\n\n var re = ''\n var hasMagic = !!options.nocase\n var escaping = false\n // ? => one single character\n var patternListStack = []\n var negativeLists = []\n var stateChar\n var inClass = false\n var reClassStart = -1\n var classStart = -1\n // . and .. never match anything that doesn't start with .,\n // even when options.dot is set.\n var patternStart = pattern.charAt(0) === '.' ? '' // anything\n // not (start or / followed by . or .. followed by / or end)\n : options.dot ? '(?!(?:^|\\\\\\/)\\\\.{1,2}(?:$|\\\\\\/))'\n : '(?!\\\\.)'\n var self = this\n\n function clearStateChar () {\n if (stateChar) {\n // we had some state-tracking character\n // that wasn't consumed by this pass.\n switch (stateChar) {\n case '*':\n re += star\n hasMagic = true\n break\n case '?':\n re += qmark\n hasMagic = true\n break\n default:\n re += '\\\\' + stateChar\n break\n }\n self.debug('clearStateChar %j %j', stateChar, re)\n stateChar = false\n }\n }\n\n for (var i = 0, len = pattern.length, c\n ; (i < len) && (c = pattern.charAt(i))\n ; i++) {\n this.debug('%s\\t%s %s %j', pattern, i, re, c)\n\n // skip over any that are escaped.\n if (escaping && reSpecials[c]) {\n re += '\\\\' + c\n escaping = false\n continue\n }\n\n switch (c) {\n case '/':\n // completely not allowed, even escaped.\n // Should already be path-split by now.\n return false\n\n case '\\\\':\n clearStateChar()\n escaping = true\n continue\n\n // the various stateChar values\n // for the \"extglob\" stuff.\n case '?':\n case '*':\n case '+':\n case '@':\n case '!':\n this.debug('%s\\t%s %s %j <-- stateChar', pattern, i, re, c)\n\n // all of those are literals inside a class, except that\n // the glob [!a] means [^a] in regexp\n if (inClass) {\n this.debug(' in class')\n if (c === '!' && i === classStart + 1) c = '^'\n re += c\n continue\n }\n\n // if we already have a stateChar, then it means\n // that there was something like ** or +? in there.\n // Handle the stateChar, then proceed with this one.\n self.debug('call clearStateChar %j', stateChar)\n clearStateChar()\n stateChar = c\n // if extglob is disabled, then +(asdf|foo) isn't a thing.\n // just clear the statechar *now*, rather than even diving into\n // the patternList stuff.\n if (options.noext) clearStateChar()\n continue\n\n case '(':\n if (inClass) {\n re += '('\n continue\n }\n\n if (!stateChar) {\n re += '\\\\('\n continue\n }\n\n patternListStack.push({\n type: stateChar,\n start: i - 1,\n reStart: re.length,\n open: plTypes[stateChar].open,\n close: plTypes[stateChar].close\n })\n // negation is (?:(?!js)[^/]*)\n re += stateChar === '!' ? '(?:(?!(?:' : '(?:'\n this.debug('plType %j %j', stateChar, re)\n stateChar = false\n continue\n\n case ')':\n if (inClass || !patternListStack.length) {\n re += '\\\\)'\n continue\n }\n\n clearStateChar()\n hasMagic = true\n var pl = patternListStack.pop()\n // negation is (?:(?!js)[^/]*)\n // The others are (?:<pattern>)<type>\n re += pl.close\n if (pl.type === '!') {\n negativeLists.push(pl)\n }\n pl.reEnd = re.length\n continue\n\n case '|':\n if (inClass || !patternListStack.length || escaping) {\n re += '\\\\|'\n escaping = false\n continue\n }\n\n clearStateChar()\n re += '|'\n continue\n\n // these are mostly the same in regexp and glob\n case '[':\n // swallow any state-tracking char before the [\n clearStateChar()\n\n if (inClass) {\n re += '\\\\' + c\n continue\n }\n\n inClass = true\n classStart = i\n reClassStart = re.length\n re += c\n continue\n\n case ']':\n // a right bracket shall lose its special\n // meaning and represent itself in\n // a bracket expression if it occurs\n // first in the list. -- POSIX.2 2.8.3.2\n if (i === classStart + 1 || !inClass) {\n re += '\\\\' + c\n escaping = false\n continue\n }\n\n // handle the case where we left a class open.\n // \"[z-a]\" is valid, equivalent to \"\\[z-a\\]\"\n if (inClass) {\n // split where the last [ was, make sure we don't have\n // an invalid re. if so, re-walk the contents of the\n // would-be class to re-translate any characters that\n // were passed through as-is\n // TODO: It would probably be faster to determine this\n // without a try/catch and a new RegExp, but it's tricky\n // to do safely. For now, this is safe and works.\n var cs = pattern.substring(classStart + 1, i)\n try {\n RegExp('[' + cs + ']')\n } catch (er) {\n // not a valid class!\n var sp = this.parse(cs, SUBPARSE)\n re = re.substr(0, reClassStart) + '\\\\[' + sp[0] + '\\\\]'\n hasMagic = hasMagic || sp[1]\n inClass = false\n continue\n }\n }\n\n // finish up the class.\n hasMagic = true\n inClass = false\n re += c\n continue\n\n default:\n // swallow any state char that wasn't consumed\n clearStateChar()\n\n if (escaping) {\n // no need\n escaping = false\n } else if (reSpecials[c]\n && !(c === '^' && inClass)) {\n re += '\\\\'\n }\n\n re += c\n\n } // switch\n } // for\n\n // handle the case where we left a class open.\n // \"[abc\" is valid, equivalent to \"\\[abc\"\n if (inClass) {\n // split where the last [ was, and escape it\n // this is a huge pita. We now have to re-walk\n // the contents of the would-be class to re-translate\n // any characters that were passed through as-is\n cs = pattern.substr(classStart + 1)\n sp = this.parse(cs, SUBPARSE)\n re = re.substr(0, reClassStart) + '\\\\[' + sp[0]\n hasMagic = hasMagic || sp[1]\n }\n\n // handle the case where we had a +( thing at the *end*\n // of the pattern.\n // each pattern list stack adds 3 chars, and we need to go through\n // and escape any | chars that were passed through as-is for the regexp.\n // Go through and escape them, taking care not to double-escape any\n // | chars that were already escaped.\n for (pl = patternListStack.pop(); pl; pl = patternListStack.pop()) {\n var tail = re.slice(pl.reStart + pl.open.length)\n this.debug('setting tail', re, pl)\n // maybe some even number of \\, then maybe 1 \\, followed by a |\n tail = tail.replace(/((?:\\\\{2}){0,64})(\\\\?)\\|/g, function (_, $1, $2) {\n if (!$2) {\n // the | isn't already escaped, so escape it.\n $2 = '\\\\'\n }\n\n // need to escape all those slashes *again*, without escaping the\n // one that we need for escaping the | character. As it works out,\n // escaping an even number of slashes can be done by simply repeating\n // it exactly after itself. That's why this trick works.\n //\n // I am sorry that you have to see this.\n return $1 + $1 + $2 + '|'\n })\n\n this.debug('tail=%j\\n %s', tail, tail, pl, re)\n var t = pl.type === '*' ? star\n : pl.type === '?' ? qmark\n : '\\\\' + pl.type\n\n hasMagic = true\n re = re.slice(0, pl.reStart) + t + '\\\\(' + tail\n }\n\n // handle trailing things that only matter at the very end.\n clearStateChar()\n if (escaping) {\n // trailing \\\\\n re += '\\\\\\\\'\n }\n\n // only need to apply the nodot start if the re starts with\n // something that could conceivably capture a dot\n var addPatternStart = false\n switch (re.charAt(0)) {\n case '.':\n case '[':\n case '(': addPatternStart = true\n }\n\n // Hack to work around lack of negative lookbehind in JS\n // A pattern like: *.!(x).!(y|z) needs to ensure that a name\n // like 'a.xyz.yz' doesn't match. So, the first negative\n // lookahead, has to look ALL the way ahead, to the end of\n // the pattern.\n for (var n = negativeLists.length - 1; n > -1; n--) {\n var nl = negativeLists[n]\n\n var nlBefore = re.slice(0, nl.reStart)\n var nlFirst = re.slice(nl.reStart, nl.reEnd - 8)\n var nlLast = re.slice(nl.reEnd - 8, nl.reEnd)\n var nlAfter = re.slice(nl.reEnd)\n\n nlLast += nlAfter\n\n // Handle nested stuff like *(*.js|!(*.json)), where open parens\n // mean that we should *not* include the ) in the bit that is considered\n // \"after\" the negated section.\n var openParensBefore = nlBefore.split('(').length - 1\n var cleanAfter = nlAfter\n for (i = 0; i < openParensBefore; i++) {\n cleanAfter = cleanAfter.replace(/\\)[+*?]?/, '')\n }\n nlAfter = cleanAfter\n\n var dollar = ''\n if (nlAfter === '' && isSub !== SUBPARSE) {\n dollar = '$'\n }\n var newRe = nlBefore + nlFirst + nlAfter + dollar + nlLast\n re = newRe\n }\n\n // if the re is not \"\" at this point, then we need to make sure\n // it doesn't match against an empty path part.\n // Otherwise a/* will match a/, which it should not.\n if (re !== '' && hasMagic) {\n re = '(?=.)' + re\n }\n\n if (addPatternStart) {\n re = patternStart + re\n }\n\n // parsing just a piece of a larger pattern.\n if (isSub === SUBPARSE) {\n return [re, hasMagic]\n }\n\n // skip the regexp for non-magical patterns\n // unescape anything in it, though, so that it'll be\n // an exact match against a file etc.\n if (!hasMagic) {\n return globUnescape(pattern)\n }\n\n var flags = options.nocase ? 'i' : ''\n try {\n var regExp = new RegExp('^' + re + '$', flags)\n } catch (er) {\n // If it was an invalid regular expression, then it can't match\n // anything. This trick looks for a character after the end of\n // the string, which is of course impossible, except in multi-line\n // mode, but it's not a /m regex.\n return new RegExp('$.')\n }\n\n regExp._glob = pattern\n regExp._src = re\n\n return regExp\n}\n\nminimatch.makeRe = function (pattern, options) {\n return new Minimatch(pattern, options || {}).makeRe()\n}\n\nMinimatch.prototype.makeRe = makeRe\nfunction makeRe () {\n if (this.regexp || this.regexp === false) return this.regexp\n\n // at this point, this.set is a 2d array of partial\n // pattern strings, or \"**\".\n //\n // It's better to use .match(). This function shouldn't\n // be used, really, but it's pretty convenient sometimes,\n // when you just want to work with a regex.\n var set = this.set\n\n if (!set.length) {\n this.regexp = false\n return this.regexp\n }\n var options = this.options\n\n var twoStar = options.noglobstar ? star\n : options.dot ? twoStarDot\n : twoStarNoDot\n var flags = options.nocase ? 'i' : ''\n\n var re = set.map(function (pattern) {\n return pattern.map(function (p) {\n return (p === GLOBSTAR) ? twoStar\n : (typeof p === 'string') ? regExpEscape(p)\n : p._src\n }).join('\\\\\\/')\n }).join('|')\n\n // must match entire pattern\n // ending in a * or ** will make it less strict.\n re = '^(?:' + re + ')$'\n\n // can match anything, as long as it's not this.\n if (this.negate) re = '^(?!' + re + ').*$'\n\n try {\n this.regexp = new RegExp(re, flags)\n } catch (ex) {\n this.regexp = false\n }\n return this.regexp\n}\n\nminimatch.match = function (list, pattern, options) {\n options = options || {}\n var mm = new Minimatch(pattern, options)\n list = list.filter(function (f) {\n return mm.match(f)\n })\n if (mm.options.nonull && !list.length) {\n list.push(pattern)\n }\n return list\n}\n\nMinimatch.prototype.match = match\nfunction match (f, partial) {\n this.debug('match', f, this.pattern)\n // short-circuit in the case of busted things.\n // comments, etc.\n if (this.comment) return false\n if (this.empty) return f === ''\n\n if (f === '/' && partial) return true\n\n var options = this.options\n\n // windows: need to use /, not \\\n if (path.sep !== '/') {\n f = f.split(path.sep).join('/')\n }\n\n // treat the test path as a set of pathparts.\n f = f.split(slashSplit)\n this.debug(this.pattern, 'split', f)\n\n // just ONE of the pattern sets in this.set needs to match\n // in order for it to be valid. If negating, then just one\n // match means that we have failed.\n // Either way, return on the first hit.\n\n var set = this.set\n this.debug(this.pattern, 'set', set)\n\n // Find the basename of the path by looking for the last non-empty segment\n var filename\n var i\n for (i = f.length - 1; i >= 0; i--) {\n filename = f[i]\n if (filename) break\n }\n\n for (i = 0; i < set.length; i++) {\n var pattern = set[i]\n var file = f\n if (options.matchBase && pattern.length === 1) {\n file = [filename]\n }\n var hit = this.matchOne(file, pattern, partial)\n if (hit) {\n if (options.flipNegate) return true\n return !this.negate\n }\n }\n\n // didn't get any hits. this is success if it's a negative\n // pattern, failure otherwise.\n if (options.flipNegate) return false\n return this.negate\n}\n\n// set partial to true to test if, for example,\n// \"/a/b\" matches the start of \"/*/b/*/d\"\n// Partial means, if you run out of file before you run\n// out of pattern, then that's fine, as long as all\n// the parts match.\nMinimatch.prototype.matchOne = function (file, pattern, partial) {\n var options = this.options\n\n this.debug('matchOne',\n { 'this': this, file: file, pattern: pattern })\n\n this.debug('matchOne', file.length, pattern.length)\n\n for (var fi = 0,\n pi = 0,\n fl = file.length,\n pl = pattern.length\n ; (fi < fl) && (pi < pl)\n ; fi++, pi++) {\n this.debug('matchOne loop')\n var p = pattern[pi]\n var f = file[fi]\n\n this.debug(pattern, p, f)\n\n // should be impossible.\n // some invalid regexp stuff in the set.\n if (p === false) return false\n\n if (p === GLOBSTAR) {\n this.debug('GLOBSTAR', [pattern, p, f])\n\n // \"**\"\n // a/**/b/**/c would match the following:\n // a/b/x/y/z/c\n // a/x/y/z/b/c\n // a/b/x/b/x/c\n // a/b/c\n // To do this, take the rest of the pattern after\n // the **, and see if it would match the file remainder.\n // If so, return success.\n // If not, the ** \"swallows\" a segment, and try again.\n // This is recursively awful.\n //\n // a/**/b/**/c matching a/b/x/y/z/c\n // - a matches a\n // - doublestar\n // - matchOne(b/x/y/z/c, b/**/c)\n // - b matches b\n // - doublestar\n // - matchOne(x/y/z/c, c) -> no\n // - matchOne(y/z/c, c) -> no\n // - matchOne(z/c, c) -> no\n // - matchOne(c, c) yes, hit\n var fr = fi\n var pr = pi + 1\n if (pr === pl) {\n this.debug('** at the end')\n // a ** at the end will just swallow the rest.\n // We have found a match.\n // however, it will not swallow /.x, unless\n // options.dot is set.\n // . and .. are *never* matched by **, for explosively\n // exponential reasons.\n for (; fi < fl; fi++) {\n if (file[fi] === '.' || file[fi] === '..' ||\n (!options.dot && file[fi].charAt(0) === '.')) return false\n }\n return true\n }\n\n // ok, let's see if we can swallow whatever we can.\n while (fr < fl) {\n var swallowee = file[fr]\n\n this.debug('\\nglobstar while', file, fr, pattern, pr, swallowee)\n\n // XXX remove this slice. Just pass the start index.\n if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {\n this.debug('globstar found match!', fr, fl, swallowee)\n // found a match.\n return true\n } else {\n // can't swallow \".\" or \"..\" ever.\n // can only swallow \".foo\" when explicitly asked.\n if (swallowee === '.' || swallowee === '..' ||\n (!options.dot && swallowee.charAt(0) === '.')) {\n this.debug('dot detected!', file, fr, pattern, pr)\n break\n }\n\n // ** swallows a segment, and continue.\n this.debug('globstar swallow a segment, and continue')\n fr++\n }\n }\n\n // no match was found.\n // However, in partial mode, we can't say this is necessarily over.\n // If there's more *pattern* left, then\n if (partial) {\n // ran out of file\n this.debug('\\n>>> no match, partial?', file, fr, pattern, pr)\n if (fr === fl) return true\n }\n return false\n }\n\n // something other than **\n // non-magic patterns just have to match exactly\n // patterns with magic have been turned into regexps.\n var hit\n if (typeof p === 'string') {\n if (options.nocase) {\n hit = f.toLowerCase() === p.toLowerCase()\n } else {\n hit = f === p\n }\n this.debug('string match', p, f, hit)\n } else {\n hit = f.match(p)\n this.debug('pattern match', p, f, hit)\n }\n\n if (!hit) return false\n }\n\n // Note: ending in / means that we'll get a final \"\"\n // at the end of the pattern. This can only match a\n // corresponding \"\" at the end of the file.\n // If the file ends in /, then it can only match a\n // a pattern that ends in /, unless the pattern just\n // doesn't have any more for it. But, a/b/ should *not*\n // match \"a/b/*\", even though \"\" matches against the\n // [^/]*? pattern, except in partial mode, where it might\n // simply not be reached yet.\n // However, a/b/ should still satisfy a/*\n\n // now either we fell off the end of the pattern, or we're done.\n if (fi === fl && pi === pl) {\n // ran out of pattern and filename at the same time.\n // an exact hit!\n return true\n } else if (fi === fl) {\n // ran out of file, but still had pattern left.\n // this is ok if we're doing the match as part of\n // a glob fs traversal.\n return partial\n } else if (pi === pl) {\n // ran out of pattern, still have file left.\n // this is only acceptable if we're on the very last\n // empty segment of a file with a trailing slash.\n // a/* should match a/b/\n var emptyFileEnd = (fi === fl - 1) && (file[fi] === '')\n return emptyFileEnd\n }\n\n // should be unreachable.\n throw new Error('wtf?')\n}\n\n// replace stuff like \\* with *\nfunction globUnescape (s) {\n return s.replace(/\\\\(.)/g, '$1')\n}\n\nfunction regExpEscape (s) {\n return s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, '\\\\$&')\n}\n","var {promisify} = require('es6-promisify');\r\nvar Path = require('../path.js');\r\nvar Errors = require('../errors.js');\r\nvar Environment = require('./environment.js');\r\nvar async = require('../../lib/async.js');\r\nvar minimatch = require('minimatch');\r\n\r\nfunction Shell(fs, options) {\r\n options = options || {};\r\n\r\n var env = new Environment(options.env);\r\n var cwd = '/';\r\n\r\n /**\r\n * The bound FileSystem (cannot be changed)\r\n */\r\n Object.defineProperty(this, 'fs', {\r\n get: function() { return fs; },\r\n enumerable: true\r\n });\r\n\r\n /**\r\n * The shell's environment (e.g., for things like\r\n * path, tmp, and other env vars). Use env.get()\r\n * and env.set() to work with variables.\r\n */\r\n Object.defineProperty(this, 'env', {\r\n get: function() { return env; },\r\n enumerable: true\r\n });\r\n\r\n /**\r\n * Change the current working directory. We\r\n * include `cd` on the `this` vs. proto so that\r\n * we can access cwd without exposing it externally.\r\n */\r\n this.cd = function(path, callback) {\r\n path = Path.resolve(cwd, path);\r\n // Make sure the path actually exists, and is a dir\r\n fs.stat(path, function(err, stats) {\r\n if(err) {\r\n callback(new Errors.ENOTDIR(null, path));\r\n return;\r\n }\r\n if(stats.type === 'DIRECTORY') {\r\n cwd = path;\r\n callback();\r\n } else {\r\n callback(new Errors.ENOTDIR(null, path));\r\n }\r\n });\r\n };\r\n\r\n /**\r\n * Get the current working directory (changed with `cd()`)\r\n */\r\n this.pwd = function() {\r\n return cwd;\r\n };\r\n\r\n this.promises = {};\r\n /**\r\n * Public API for Shell converted to Promise based\r\n */\r\n [\r\n 'cd',\r\n 'exec',\r\n 'touch',\r\n 'cat',\r\n 'ls',\r\n 'rm',\r\n 'tempDir',\r\n 'mkdirp',\r\n 'find'\r\n ].forEach((methodName)=>{\r\n this.promises[methodName] = promisify(this[methodName].bind(this));\r\n });\r\n}\r\n\r\n/**\r\n * Execute the .js command located at `path`. Such commands\r\n * should assume the existence of 3 arguments, which will be\r\n * defined at runtime:\r\n *\r\n * * fs - the current shell's bound filesystem object\r\n * * args - a list of arguments for the command, or an empty list if none\r\n * * callback - a callback function(error, result) to call when done.\r\n *\r\n * The .js command's contents should be the body of a function\r\n * that looks like this:\r\n *\r\n * function(fs, args, callback) {\r\n * // .js code here\r\n * }\r\n */\r\nShell.prototype.exec = function(path, args, callback) {\r\n /* jshint evil:true */\r\n var sh = this;\r\n var fs = sh.fs;\r\n if(typeof args === 'function') {\r\n callback = args;\r\n args = [];\r\n }\r\n args = args || [];\r\n callback = callback || function(){};\r\n path = Path.resolve(sh.pwd(), path);\r\n\r\n fs.readFile(path, 'utf8', function(error, data) {\r\n if(error) {\r\n callback(error);\r\n return;\r\n }\r\n try {\r\n var cmd = new Function('fs', 'args', 'callback', data);\r\n cmd(fs, args, callback);\r\n } catch(e) {\r\n callback(e);\r\n }\r\n });\r\n};\r\n\r\n/**\r\n * Create a file if it does not exist, or update access and\r\n * modified times if it does. Valid options include:\r\n *\r\n * * updateOnly - whether to create the file if missing (defaults to false)\r\n * * date - use the provided Date value instead of current date/time\r\n */\r\nShell.prototype.touch = function(path, options, callback) {\r\n var sh = this;\r\n var fs = sh.fs;\r\n if(typeof options === 'function') {\r\n callback = options;\r\n options = {};\r\n }\r\n options = options || {};\r\n callback = callback || function(){};\r\n path = Path.resolve(sh.pwd(), path);\r\n\r\n function createFile(path) {\r\n fs.writeFile(path, '', callback);\r\n }\r\n\r\n function updateTimes(path) {\r\n var now = Date.now();\r\n var atime = options.date || now;\r\n var mtime = options.date || now;\r\n\r\n fs.utimes(path, atime, mtime, callback);\r\n }\r\n\r\n fs.stat(path, function(error) {\r\n if(error) {\r\n if(options.updateOnly === true) {\r\n callback();\r\n } else {\r\n createFile(path);\r\n }\r\n } else {\r\n updateTimes(path);\r\n }\r\n });\r\n};\r\n\r\n/**\r\n * Concatenate multiple files into a single String, with each\r\n * file separated by a newline. The `files` argument should\r\n * be a String (path to single file) or an Array of Strings\r\n * (multiple file paths).\r\n */\r\nShell.prototype.cat = function(files, callback) {\r\n var sh = this;\r\n var fs = sh.fs;\r\n var all = '';\r\n callback = callback || function(){};\r\n\r\n if(!files) {\r\n callback(new Errors.EINVAL('Missing files argument'));\r\n return;\r\n }\r\n\r\n files = typeof files === 'string' ? [ files ] : files;\r\n\r\n function append(item, callback) {\r\n var filename = Path.resolve(sh.pwd(), item);\r\n fs.readFile(filename, 'utf8', function(error, data) {\r\n if(error) {\r\n callback(error);\r\n return;\r\n }\r\n all += data + '\\n';\r\n callback();\r\n });\r\n }\r\n\r\n async.eachSeries(files, append, function(error) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n callback(null, all.replace(/\\n$/, ''));\r\n }\r\n });\r\n};\r\n\r\n/**\r\n * Get the listing of a directory, returning an array of\r\n * file entries in the following form:\r\n *\r\n * {\r\n * path: <String> the basename of the directory entry\r\n * links: <Number> the number of links to the entry\r\n * size: <Number> the size in bytes of the entry\r\n * modified: <Number> the last modified date/time\r\n * type: <String> the type of the entry\r\n * contents: <Array> an optional array of child entries\r\n * }\r\n *\r\n * By default ls() gives a shallow listing. If you want\r\n * to follow directories as they are encountered, use\r\n * the `recursive=true` option.\r\n */\r\nShell.prototype.ls = function(dir, options, callback) {\r\n var sh = this;\r\n var fs = sh.fs;\r\n if(typeof options === 'function') {\r\n callback = options;\r\n options = {};\r\n }\r\n options = options || {};\r\n callback = callback || function(){};\r\n\r\n if(!dir) {\r\n callback(new Errors.EINVAL('Missing dir argument'));\r\n return;\r\n }\r\n\r\n function list(path, callback) {\r\n var pathname = Path.resolve(sh.pwd(), path);\r\n var result = [];\r\n\r\n fs.readdir(pathname, function(error, entries) {\r\n if(error) {\r\n callback(error);\r\n return;\r\n }\r\n\r\n function getDirEntry(name, callback) {\r\n name = Path.join(pathname, name);\r\n fs.stat(name, function(error, stats) {\r\n if(error) {\r\n callback(error);\r\n return;\r\n }\r\n var entry = stats;\r\n\r\n if(options.recursive && stats.type === 'DIRECTORY') {\r\n list(Path.join(pathname, entry.name), function(error, items) {\r\n if(error) {\r\n callback(error);\r\n return;\r\n }\r\n entry.contents = items;\r\n result.push(entry);\r\n callback();\r\n });\r\n } else {\r\n result.push(entry);\r\n callback();\r\n }\r\n });\r\n }\r\n\r\n async.eachSeries(entries, getDirEntry, function(error) {\r\n callback(error, result);\r\n });\r\n });\r\n }\r\n\r\n list(dir, callback);\r\n};\r\n\r\n/**\r\n * Removes the file or directory at `path`. If `path` is a file\r\n * it will be removed. If `path` is a directory, it will be\r\n * removed if it is empty, otherwise the callback will receive\r\n * an error. In order to remove non-empty directories, use the\r\n * `recursive=true` option.\r\n */\r\nShell.prototype.rm = function(path, options, callback) {\r\n var sh = this;\r\n var fs = sh.fs;\r\n if(typeof options === 'function') {\r\n callback = options;\r\n options = {};\r\n }\r\n options = options || {};\r\n callback = callback || function(){};\r\n\r\n if(!path) {\r\n callback(new Errors.EINVAL('Missing path argument'));\r\n return;\r\n }\r\n\r\n function remove(pathname, callback) {\r\n pathname = Path.resolve(sh.pwd(), pathname);\r\n fs.stat(pathname, function(error, stats) {\r\n if(error) {\r\n callback(error);\r\n return;\r\n }\r\n\r\n // If this is a file, delete it and we're done\r\n if(stats.type === 'FILE') {\r\n fs.unlink(pathname, callback);\r\n return;\r\n }\r\n\r\n // If it's a dir, check if it's empty\r\n fs.readdir(pathname, function(error, entries) {\r\n if(error) {\r\n callback(error);\r\n return;\r\n }\r\n\r\n // If dir is empty, delete it and we're done\r\n if(entries.length === 0) {\r\n fs.rmdir(pathname, callback);\r\n return;\r\n }\r\n\r\n // If not, see if we're allowed to delete recursively\r\n if(!options.recursive) {\r\n callback(new Errors.ENOTEMPTY(null, pathname));\r\n return;\r\n }\r\n\r\n // Remove each dir entry recursively, then delete the dir.\r\n entries = entries.map(function(filename) {\r\n // Root dir entries absolutely\r\n return Path.join(pathname, filename);\r\n });\r\n async.eachSeries(entries, remove, function(error) {\r\n if(error) {\r\n callback(error);\r\n return;\r\n }\r\n fs.rmdir(pathname, callback);\r\n });\r\n });\r\n });\r\n }\r\n\r\n remove(path, callback);\r\n};\r\n\r\n/**\r\n * Gets the path to the temporary directory, creating it if not\r\n * present. The directory used is the one specified in\r\n * env.TMP. The callback receives (error, tempDirName).\r\n */\r\nShell.prototype.tempDir = function(callback) {\r\n var sh = this;\r\n var fs = sh.fs;\r\n var tmp = sh.env.get('TMP');\r\n callback = callback || function(){};\r\n\r\n // Try and create it, and it will either work or fail\r\n // but either way it's now there.\r\n fs.mkdir(tmp, function() {\r\n callback(null, tmp);\r\n });\r\n};\r\n\r\n/**\r\n * Recursively creates the directory at `path`. If the parent\r\n * of `path` does not exist, it will be created.\r\n * Based off EnsureDir by Sam X. Xu\r\n * https://www.npmjs.org/package/ensureDir\r\n * MIT License\r\n */\r\nShell.prototype.mkdirp = function(path, callback) {\r\n var sh = this;\r\n var fs = sh.fs;\r\n callback = callback || function(){};\r\n\r\n if(!path) {\r\n callback(new Errors.EINVAL('Missing path argument'));\r\n return;\r\n }\r\n else if (path === '/') {\r\n callback();\r\n return;\r\n }\r\n function _mkdirp(path, callback) {\r\n fs.stat(path, function (err, stat) {\r\n if(stat) {\r\n if(stat.isDirectory()) {\r\n callback();\r\n return;\r\n }\r\n else if (stat.isFile()) {\r\n callback(new Errors.ENOTDIR(null, path));\r\n return;\r\n }\r\n }\r\n else if (err && err.code !== 'ENOENT') {\r\n callback(err);\r\n return;\r\n }\r\n else {\r\n var parent = Path.dirname(path);\r\n if(parent === '/') {\r\n fs.mkdir(path, function (err) {\r\n if (err && err.code != 'EEXIST') {\r\n callback(err);\r\n return;\r\n }\r\n callback();\r\n return;\r\n });\r\n }\r\n else {\r\n _mkdirp(parent, function (err) {\r\n if (err) return callback(err);\r\n fs.mkdir(path, function (err) {\r\n if (err && err.code != 'EEXIST') {\r\n callback(err);\r\n return;\r\n }\r\n callback();\r\n return;\r\n });\r\n });\r\n }\r\n }\r\n });\r\n }\r\n\r\n _mkdirp(path, callback);\r\n};\r\n\r\n/**\r\n * Recursively walk a directory tree, reporting back all paths\r\n * that were found along the way. The `path` must be a dir.\r\n * Valid options include a `regex` for pattern matching paths\r\n * and an `exec` function of the form `function(path, next)` where\r\n * `path` is the current path that was found (dir paths have an '/'\r\n * appended) and `next` is a callback to call when done processing\r\n * the current path, passing any error object back as the first argument.\r\n * `find` returns a flat array of absolute paths for all matching/found\r\n * paths as the final argument to the callback.\r\n */\r\nShell.prototype.find = function(path, options, callback) {\r\n var sh = this;\r\n var fs = sh.fs;\r\n if(typeof options === 'function') {\r\n callback = options;\r\n options = {};\r\n }\r\n options = options || {};\r\n callback = callback || function(){};\r\n\r\n var exec = options.exec || function(path, next) { next(); };\r\n var found = [];\r\n\r\n if(!path) {\r\n callback(new Errors.EINVAL('Missing path argument'));\r\n return;\r\n }\r\n\r\n function processPath(path, callback) {\r\n exec(path, function(err) {\r\n if(err) {\r\n callback(err);\r\n return;\r\n }\r\n\r\n found.push(path);\r\n callback();\r\n });\r\n }\r\n\r\n function maybeProcessPath(path, callback) {\r\n // Test the path against the user's regex, name, path primaries (if any)\r\n // and remove any trailing slashes added previously.\r\n var rawPath = Path.removeTrailing(path);\r\n\r\n // Check entire path against provided regex, if any\r\n if(options.regex && !options.regex.test(rawPath)) {\r\n callback();\r\n return;\r\n }\r\n\r\n // Check basename for matches against name primary, if any\r\n if(options.name && !minimatch(Path.basename(rawPath), options.name)) {\r\n callback();\r\n return;\r\n }\r\n\r\n // Check dirname for matches against path primary, if any\r\n if(options.path && !minimatch(Path.dirname(rawPath), options.path)) {\r\n callback();\r\n return;\r\n }\r\n\r\n processPath(path, callback);\r\n }\r\n\r\n function walk(path, callback) {\r\n path = Path.resolve(sh.pwd(), path);\r\n\r\n // The path is either a file or dir, and instead of doing\r\n // a stat() to determine it first, we just try to readdir()\r\n // and it will either work or not, and we handle the non-dir error.\r\n fs.readdir(path, function(err, entries) {\r\n if(err) {\r\n if(err.code === 'ENOTDIR' /* file case, ignore error */) {\r\n maybeProcessPath(path, callback);\r\n } else {\r\n callback(err);\r\n }\r\n return;\r\n }\r\n\r\n // Path is really a dir, add a trailing / and report it found\r\n maybeProcessPath(Path.addTrailing(path), function(err) {\r\n if(err) {\r\n callback(err);\r\n return;\r\n }\r\n\r\n entries = entries.map(function(entry) {\r\n return Path.join(path, entry);\r\n });\r\n\r\n async.eachSeries(entries, walk, function(err) {\r\n callback(err, found);\r\n });\r\n });\r\n });\r\n }\r\n\r\n // Make sure we are starting with a dir path\r\n fs.stat(path, function(err, stats) {\r\n if(err) {\r\n callback(err);\r\n return;\r\n }\r\n if(!stats.isDirectory()) {\r\n callback(new Errors.ENOTDIR(null, path));\r\n return;\r\n }\r\n\r\n walk(path, callback);\r\n });\r\n};\r\n\r\nmodule.exports = Shell;\r\n","// Based on https://github.com/diy/intercom.js/blob/master/lib/events.js\r\n// Copyright 2012 DIY Co Apache License, Version 2.0\r\n// http://www.apache.org/licenses/LICENSE-2.0\r\n\r\nfunction removeItem(item, array) {\r\n for (var i = array.length - 1; i >= 0; i--) {\r\n if (array[i] === item) {\r\n array.splice(i, 1);\r\n }\r\n }\r\n return array;\r\n}\r\n\r\nvar EventEmitter = function() {};\r\n\r\nEventEmitter.createInterface = function(space) {\r\n var methods = {};\r\n\r\n methods.on = function(name, fn) {\r\n if (typeof this[space] === 'undefined') {\r\n this[space] = {};\r\n }\r\n if (!this[space].hasOwnProperty(name)) {\r\n this[space][name] = [];\r\n }\r\n this[space][name].push(fn);\r\n };\r\n\r\n methods.off = function(name, fn) {\r\n if (typeof this[space] === 'undefined') return;\r\n if (this[space].hasOwnProperty(name)) {\r\n removeItem(fn, this[space][name]);\r\n }\r\n };\r\n\r\n methods.trigger = function(name) {\r\n if (typeof this[space] !== 'undefined' && this[space].hasOwnProperty(name)) {\r\n var args = Array.prototype.slice.call(arguments, 1);\r\n for (var i = 0; i < this[space][name].length; i++) {\r\n this[space][name][i].apply(this[space][name][i], args);\r\n }\r\n }\r\n };\r\n\r\n methods.removeAllListeners = function(name) {\r\n if (typeof this[space] === 'undefined') return;\r\n var self = this;\r\n self[space][name].forEach(function(fn) {\r\n self.off(name, fn);\r\n });\r\n };\r\n\r\n return methods;\r\n};\r\n\r\nvar pvt = EventEmitter.createInterface('_handlers');\r\nEventEmitter.prototype._on = pvt.on;\r\nEventEmitter.prototype._off = pvt.off;\r\nEventEmitter.prototype._trigger = pvt.trigger;\r\n\r\nvar pub = EventEmitter.createInterface('handlers');\r\nEventEmitter.prototype.on = function() {\r\n pub.on.apply(this, arguments);\r\n Array.prototype.unshift.call(arguments, 'on');\r\n this._trigger.apply(this, arguments);\r\n};\r\nEventEmitter.prototype.off = pub.off;\r\nEventEmitter.prototype.trigger = pub.trigger;\r\nEventEmitter.prototype.removeAllListeners = pub.removeAllListeners;\r\n\r\nmodule.exports = EventEmitter;\r\n","// Based on https://github.com/diy/intercom.js/blob/master/lib/intercom.js\r\n// Copyright 2012 DIY Co Apache License, Version 2.0\r\n// http://www.apache.org/licenses/LICENSE-2.0\r\n\r\nvar EventEmitter = require('./eventemitter.js');\r\nvar guid = require('../src/shared.js').guid;\r\n\r\nfunction throttle(delay, fn) {\r\n var last = 0;\r\n return function() {\r\n var now = Date.now();\r\n if (now - last > delay) {\r\n last = now;\r\n fn.apply(this, arguments);\r\n }\r\n };\r\n}\r\n\r\nfunction extend(a, b) {\r\n if (typeof a === 'undefined' || !a) { a = {}; }\r\n if (typeof b === 'object') {\r\n for (var key in b) {\r\n if (b.hasOwnProperty(key)) {\r\n a[key] = b[key];\r\n }\r\n }\r\n }\r\n return a;\r\n}\r\n\r\nvar localStorage = (function(window) {\r\n if (typeof window === 'undefined' ||\r\n typeof window.localStorage === 'undefined') {\r\n return {\r\n getItem : function() {},\r\n setItem : function() {},\r\n removeItem : function() {}\r\n };\r\n }\r\n return window.localStorage;\r\n}(global));\r\n\r\nfunction Intercom() {\r\n var self = this;\r\n var now = Date.now();\r\n\r\n this.origin = guid();\r\n this.lastMessage = now;\r\n this.receivedIDs = {};\r\n this.previousValues = {};\r\n\r\n var storageHandler = function() {\r\n self._onStorageEvent.apply(self, arguments);\r\n };\r\n\r\n // If we're in node.js, skip event registration\r\n if (typeof document === 'undefined') {\r\n return;\r\n }\r\n\r\n if (document.attachEvent) {\r\n document.attachEvent('onstorage', storageHandler);\r\n } else {\r\n global.addEventListener('storage', storageHandler, false);\r\n }\r\n}\r\n\r\nIntercom.prototype._transaction = function(fn) {\r\n var TIMEOUT = 1000;\r\n var WAIT = 20;\r\n var self = this;\r\n var executed = false;\r\n var listening = false;\r\n var waitTimer = null;\r\n\r\n function lock() {\r\n if (executed) {\r\n return;\r\n }\r\n\r\n var now = Date.now();\r\n var activeLock = localStorage.getItem(INDEX_LOCK)|0;\r\n if (activeLock && now - activeLock < TIMEOUT) {\r\n if (!listening) {\r\n self._on('storage', lock);\r\n listening = true;\r\n }\r\n waitTimer = setTimeout(lock, WAIT);\r\n return;\r\n }\r\n executed = true;\r\n localStorage.setItem(INDEX_LOCK, now);\r\n\r\n fn();\r\n unlock();\r\n }\r\n\r\n function unlock() {\r\n if (listening) {\r\n self._off('storage', lock);\r\n }\r\n if (waitTimer) {\r\n clearTimeout(waitTimer);\r\n }\r\n localStorage.removeItem(INDEX_LOCK);\r\n }\r\n\r\n lock();\r\n};\r\n\r\nIntercom.prototype._cleanup_emit = throttle(100, function() {\r\n var self = this;\r\n\r\n self._transaction(function() {\r\n var now = Date.now();\r\n var threshold = now - THRESHOLD_TTL_EMIT;\r\n var changed = 0;\r\n var messages;\r\n\r\n try {\r\n messages = JSON.parse(localStorage.getItem(INDEX_EMIT) || '[]');\r\n } catch(e) {\r\n messages = [];\r\n }\r\n for (var i = messages.length - 1; i >= 0; i--) {\r\n if (messages[i].timestamp < threshold) {\r\n messages.splice(i, 1);\r\n changed++;\r\n }\r\n }\r\n if (changed > 0) {\r\n localStorage.setItem(INDEX_EMIT, JSON.stringify(messages));\r\n }\r\n });\r\n});\r\n\r\nIntercom.prototype._cleanup_once = throttle(100, function() {\r\n var self = this;\r\n\r\n self._transaction(function() {\r\n var timestamp, ttl, key;\r\n var table;\r\n var now = Date.now();\r\n var changed = 0;\r\n\r\n try {\r\n table = JSON.parse(localStorage.getItem(INDEX_ONCE) || '{}');\r\n } catch(e) {\r\n table = {};\r\n }\r\n for (key in table) {\r\n if (self._once_expired(key, table)) {\r\n delete table[key];\r\n changed++;\r\n }\r\n }\r\n\r\n if (changed > 0) {\r\n localStorage.setItem(INDEX_ONCE, JSON.stringify(table));\r\n }\r\n });\r\n});\r\n\r\nIntercom.prototype._once_expired = function(key, table) {\r\n if (!table) {\r\n return true;\r\n }\r\n if (!table.hasOwnProperty(key)) {\r\n return true;\r\n }\r\n if (typeof table[key] !== 'object') {\r\n return true;\r\n }\r\n\r\n var ttl = table[key].ttl || THRESHOLD_TTL_ONCE;\r\n var now = Date.now();\r\n var timestamp = table[key].timestamp;\r\n return timestamp < now - ttl;\r\n};\r\n\r\nIntercom.prototype._localStorageChanged = function(event, field) {\r\n if (event && event.key) {\r\n return event.key === field;\r\n }\r\n\r\n var currentValue = localStorage.getItem(field);\r\n if (currentValue === this.previousValues[field]) {\r\n return false;\r\n }\r\n this.previousValues[field] = currentValue;\r\n return true;\r\n};\r\n\r\nIntercom.prototype._onStorageEvent = function(event) {\r\n event = event || global.event;\r\n var self = this;\r\n\r\n if (this._localStorageChanged(event, INDEX_EMIT)) {\r\n this._transaction(function() {\r\n var now = Date.now();\r\n var data = localStorage.getItem(INDEX_EMIT);\r\n var messages;\r\n\r\n try {\r\n messages = JSON.parse(data || '[]');\r\n } catch(e) {\r\n messages = [];\r\n }\r\n for (var i = 0; i < messages.length; i++) {\r\n if (messages[i].origin === self.origin) continue;\r\n if (messages[i].timestamp < self.lastMessage) continue;\r\n if (messages[i].id) {\r\n if (self.receivedIDs.hasOwnProperty(messages[i].id)) continue;\r\n self.receivedIDs[messages[i].id] = true;\r\n }\r\n self.trigger(messages[i].name, messages[i].payload);\r\n }\r\n self.lastMessage = now;\r\n });\r\n }\r\n\r\n this._trigger('storage', event);\r\n};\r\n\r\nIntercom.prototype._emit = function(name, message, id) {\r\n id = (typeof id === 'string' || typeof id === 'number') ? String(id) : null;\r\n if (id && id.length) {\r\n if (this.receivedIDs.hasOwnProperty(id)) return;\r\n this.receivedIDs[id] = true;\r\n }\r\n\r\n var packet = {\r\n id : id,\r\n name : name,\r\n origin : this.origin,\r\n timestamp : Date.now(),\r\n payload : message\r\n };\r\n\r\n var self = this;\r\n this._transaction(function() {\r\n var data = localStorage.getItem(INDEX_EMIT) || '[]';\r\n var delimiter = (data === '[]') ? '' : ',';\r\n data = [data.substring(0, data.length - 1), delimiter, JSON.stringify(packet), ']'].join('');\r\n localStorage.setItem(INDEX_EMIT, data);\r\n self.trigger(name, message);\r\n\r\n setTimeout(function() {\r\n self._cleanup_emit();\r\n }, 50);\r\n });\r\n};\r\n\r\nIntercom.prototype.emit = function(name, message) {\r\n this._emit.apply(this, arguments);\r\n this._trigger('emit', name, message);\r\n};\r\n\r\nIntercom.prototype.once = function(key, fn, ttl) {\r\n if (!Intercom.supported) {\r\n return;\r\n }\r\n\r\n var self = this;\r\n this._transaction(function() {\r\n var data;\r\n try {\r\n data = JSON.parse(localStorage.getItem(INDEX_ONCE) || '{}');\r\n } catch(e) {\r\n data = {};\r\n }\r\n if (!self._once_expired(key, data)) {\r\n return;\r\n }\r\n\r\n data[key] = {};\r\n data[key].timestamp = Date.now();\r\n if (typeof ttl === 'number') {\r\n data[key].ttl = ttl * 1000;\r\n }\r\n\r\n localStorage.setItem(INDEX_ONCE, JSON.stringify(data));\r\n fn();\r\n\r\n setTimeout(function() {\r\n self._cleanup_once();\r\n }, 50);\r\n });\r\n};\r\n\r\nextend(Intercom.prototype, EventEmitter.prototype);\r\n\r\nIntercom.supported = (typeof localStorage !== 'undefined');\r\n\r\nvar INDEX_EMIT = 'intercom';\r\nvar INDEX_ONCE = 'intercom_once';\r\nvar INDEX_LOCK = 'intercom_lock';\r\n\r\nvar THRESHOLD_TTL_EMIT = 50000;\r\nvar THRESHOLD_TTL_ONCE = 1000 * 3600;\r\n\r\nIntercom.destroy = function() {\r\n localStorage.removeItem(INDEX_LOCK);\r\n localStorage.removeItem(INDEX_EMIT);\r\n localStorage.removeItem(INDEX_ONCE);\r\n};\r\n\r\nIntercom.getInstance = (function() {\r\n var intercom;\r\n return function() {\r\n if (!intercom) {\r\n intercom = new Intercom();\r\n }\r\n return intercom;\r\n };\r\n})();\r\n\r\nmodule.exports = Intercom;\r\n","var EventEmitter = require('../lib/eventemitter.js');\r\nvar Path = require('./path.js');\r\nvar Intercom = require('../lib/intercom.js');\r\n\r\n/**\r\n * FSWatcher based on node.js' FSWatcher\r\n * see https://github.com/joyent/node/blob/master/lib/fs.js\r\n */\r\nfunction FSWatcher() {\r\n EventEmitter.call(this);\r\n var self = this;\r\n var recursive = false;\r\n var recursivePathPrefix;\r\n var filename;\r\n\r\n function onchange(path) {\r\n // Watch for exact filename, or parent path when recursive is true.\r\n if(filename === path || (recursive && path.indexOf(recursivePathPrefix) === 0)) {\r\n self.trigger('change', 'change', path);\r\n }\r\n }\r\n\r\n // We support, but ignore the second arg, which node.js uses.\r\n self.start = function(filename_, persistent_, recursive_) {\r\n // Bail if we've already started (and therefore have a filename);\r\n if(filename) {\r\n return;\r\n }\r\n\r\n if(Path.isNull(filename_)) {\r\n throw new Error('Path must be a string without null bytes.');\r\n }\r\n\r\n // TODO: get realpath for symlinks on filename...\r\n\r\n // Filer's Path.normalize strips trailing slashes, which we use here.\r\n // See https://github.com/js-platform/filer/issues/105\r\n filename = Path.normalize(filename_);\r\n\r\n // Whether to watch beneath this path or not\r\n recursive = recursive_ === true;\r\n // If recursive, construct a path prefix portion for comparisons later\r\n // (i.e., '/path' becomes '/path/' so we can search within a filename for the\r\n // prefix). We also take care to allow for '/' on its own.\r\n if(recursive) {\r\n recursivePathPrefix = filename === '/' ? '/' : filename + '/';\r\n }\r\n\r\n var intercom = Intercom.getInstance();\r\n intercom.on('change', onchange);\r\n };\r\n\r\n self.close = function() {\r\n var intercom = Intercom.getInstance();\r\n intercom.off('change', onchange);\r\n self.removeAllListeners('change');\r\n };\r\n}\r\nFSWatcher.prototype = new EventEmitter();\r\nFSWatcher.prototype.constructor = FSWatcher;\r\n\r\nmodule.exports = FSWatcher;\r\n","// Adapt encodings to work with Buffer or Uint8Array, they expect the latter\r\nfunction decode(buf) {\r\n return buf.toString('utf8');\r\n}\r\n\r\nfunction encode(string) {\r\n return new Buffer(string, 'utf8');\r\n}\r\n\r\nmodule.exports = {\r\n encode: encode,\r\n decode: decode\r\n};\r\n","var NODE_TYPE_FILE = require('./constants.js').NODE_TYPE_FILE;\r\n\r\nmodule.exports = function DirectoryEntry(id, type) {\r\n this.id = id;\r\n this.type = type || NODE_TYPE_FILE;\r\n};\r\n","var Errors = require('./errors.js');\r\n\r\nfunction OpenFileDescription(path, id, flags, position) {\r\n this.path = path;\r\n this.id = id;\r\n this.flags = flags;\r\n this.position = position;\r\n}\r\n\r\n// Tries to find the node associated with an ofd's `id`.\r\n// If not found, an error is returned on the callback.\r\nOpenFileDescription.prototype.getNode = function(context, callback) {\r\n var id = this.id;\r\n var path = this.path;\r\n\r\n function check_if_node_exists(error, node) {\r\n if(error) {\r\n return callback(error);\r\n }\r\n\r\n if(!node) {\r\n return callback(new Errors.EBADF('file descriptor refers to unknown node', path));\r\n }\r\n\r\n callback(null, node);\r\n }\r\n\r\n context.getObject(id, check_if_node_exists);\r\n};\r\n\r\nmodule.exports = OpenFileDescription;\r\n","var Constants = require('./constants.js');\r\n\r\nfunction SuperNode(options) {\r\n var now = Date.now();\r\n\r\n this.id = Constants.SUPER_NODE_ID;\r\n this.type = Constants.NODE_TYPE_META;\r\n this.atime = options.atime || now;\r\n this.ctime = options.ctime || now;\r\n this.mtime = options.mtime || now;\r\n // root node id (randomly generated)\r\n this.rnode = options.rnode;\r\n}\r\n\r\nSuperNode.create = function(options, callback) {\r\n options.guid(function(err, rnode) {\r\n if(err) {\r\n callback(err);\r\n return;\r\n }\r\n options.rnode = options.rnode || rnode;\r\n callback(null, new SuperNode(options));\r\n });\r\n};\r\n\r\nmodule.exports = SuperNode;\r\n","var NODE_TYPE_FILE = require('./constants.js').NODE_TYPE_FILE;\r\nvar NODE_TYPE_DIRECTORY = require('./constants.js').NODE_TYPE_DIRECTORY;\r\nvar NODE_TYPE_SYMBOLIC_LINK = require('./constants.js').NODE_TYPE_SYMBOLIC_LINK;\r\n\r\nvar S_IFREG = require('./constants.js').S_IFREG;\r\nvar S_IFDIR = require('./constants.js').S_IFDIR;\r\nvar S_IFLNK = require('./constants.js').S_IFLNK;\r\n\r\nvar DEFAULT_FILE_PERMISSIONS = require('./constants.js').DEFAULT_FILE_PERMISSIONS;\r\nvar DEFAULT_DIR_PERMISSIONS = require('./constants.js').DEFAULT_DIR_PERMISSIONS;\r\n\r\nfunction getMode(type, mode) {\r\n switch(type) {\r\n case NODE_TYPE_DIRECTORY:\r\n return (mode || DEFAULT_DIR_PERMISSIONS) | S_IFDIR;\r\n case NODE_TYPE_SYMBOLIC_LINK:\r\n return (mode || DEFAULT_FILE_PERMISSIONS) | S_IFLNK;\r\n /* jshint -W086 */\r\n case NODE_TYPE_FILE:\r\n // falls through\r\n default:\r\n return (mode || DEFAULT_FILE_PERMISSIONS) | S_IFREG;\r\n }\r\n}\r\n\r\nfunction Node(options) {\r\n var now = Date.now();\r\n\r\n this.id = options.id;\r\n this.type = options.type || NODE_TYPE_FILE; // node type (file, directory, etc)\r\n this.size = options.size || 0; // size (bytes for files, entries for directories)\r\n this.atime = options.atime || now; // access time (will mirror ctime after creation)\r\n this.ctime = options.ctime || now; // creation/change time\r\n this.mtime = options.mtime || now; // modified time\r\n this.flags = options.flags || []; // file flags\r\n this.xattrs = options.xattrs || {}; // extended attributes\r\n this.nlinks = options.nlinks || 0; // links count\r\n this.data = options.data; // id for data object\r\n this.version = options.version || 1;\r\n\r\n // permissions and flags\r\n this.mode = options.mode || (getMode(this.type));\r\n this.uid = options.uid || 0x0; // owner name\r\n this.gid = options.gid || 0x0; // group name\r\n}\r\n\r\n// Make sure the options object has an id on property,\r\n// either from caller or one we generate using supplied guid fn.\r\nfunction ensureID(options, prop, callback) {\r\n if(options[prop]) {\r\n callback(null);\r\n } else {\r\n options.guid(function(err, id) {\r\n options[prop] = id;\r\n callback(err);\r\n });\r\n }\r\n}\r\n\r\nNode.create = function(options, callback) {\r\n // We expect both options.id and options.data to be provided/generated.\r\n ensureID(options, 'id', function(err) {\r\n if(err) {\r\n callback(err);\r\n return;\r\n }\r\n\r\n ensureID(options, 'data', function(err) {\r\n if(err) {\r\n callback(err);\r\n return;\r\n }\r\n\r\n callback(null, new Node(options));\r\n });\r\n });\r\n};\r\n\r\n// Update the node's mode (permissions), taking file type bits into account.\r\nNode.setMode = function(mode, node) {\r\n node.mode = getMode(node.type, mode);\r\n};\r\n\r\nmodule.exports = Node;\r\n","var Constants = require('./constants.js');\r\nvar Path = require('./path.js');\r\n\r\nfunction Stats(path, fileNode, devName) {\r\n this.dev = devName;\r\n this.node = fileNode.id;\r\n this.type = fileNode.type;\r\n this.size = fileNode.size;\r\n this.nlinks = fileNode.nlinks;\r\n this.atime = fileNode.atime;\r\n this.mtime = fileNode.mtime;\r\n this.ctime = fileNode.ctime;\r\n this.version = fileNode.version;\r\n this.mode = fileNode.mode;\r\n this.uid = fileNode.uid;\r\n this.gid = fileNode.gid;\r\n this.name = Path.basename(path);\r\n}\r\n\r\nStats.prototype.isFile = function() {\r\n return this.type === Constants.NODE_TYPE_FILE;\r\n};\r\n\r\nStats.prototype.isDirectory = function() {\r\n return this.type === Constants.NODE_TYPE_DIRECTORY;\r\n};\r\n\r\nStats.prototype.isSymbolicLink = function() {\r\n return this.type === Constants.NODE_TYPE_SYMBOLIC_LINK;\r\n};\r\n\r\n// These will always be false in Filer.\r\nStats.prototype.isSocket =\r\nStats.prototype.isFIFO =\r\nStats.prototype.isCharacterDevice =\r\nStats.prototype.isBlockDevice =\r\nfunction() {\r\n return false;\r\n};\r\n\r\nmodule.exports = Stats;\r\n","var _ = require('../../lib/nodash.js');\r\n\r\nvar Path = require('../path.js');\r\nvar normalize = Path.normalize;\r\nvar dirname = Path.dirname;\r\nvar basename = Path.basename;\r\nvar isAbsolutePath = Path.isAbsolute;\r\nvar isNullPath = Path.isNull;\r\n\r\nvar Constants = require('../constants.js');\r\nvar NODE_TYPE_FILE = Constants.NODE_TYPE_FILE;\r\nvar NODE_TYPE_DIRECTORY = Constants.NODE_TYPE_DIRECTORY;\r\nvar NODE_TYPE_SYMBOLIC_LINK = Constants.NODE_TYPE_SYMBOLIC_LINK;\r\nvar NODE_TYPE_META = Constants.NODE_TYPE_META;\r\n\r\nvar FULL_READ_WRITE_EXEC_PERMISSIONS = Constants.FULL_READ_WRITE_EXEC_PERMISSIONS;\r\n\r\nvar ROOT_DIRECTORY_NAME = Constants.ROOT_DIRECTORY_NAME;\r\nvar SUPER_NODE_ID = Constants.SUPER_NODE_ID;\r\nvar SYMLOOP_MAX = Constants.SYMLOOP_MAX;\r\n\r\nvar O_READ = Constants.O_READ;\r\nvar O_WRITE = Constants.O_WRITE;\r\nvar O_CREATE = Constants.O_CREATE;\r\nvar O_EXCLUSIVE = Constants.O_EXCLUSIVE;\r\nvar O_APPEND = Constants.O_APPEND;\r\nvar O_FLAGS = Constants.O_FLAGS;\r\n\r\nvar XATTR_CREATE = Constants.XATTR_CREATE;\r\nvar XATTR_REPLACE = Constants.XATTR_REPLACE;\r\nvar FS_NOMTIME = Constants.FS_NOMTIME;\r\nvar FS_NOCTIME = Constants.FS_NOCTIME;\r\n\r\nvar Encoding = require('../encoding.js');\r\nvar Errors = require('../errors.js');\r\nvar DirectoryEntry = require('../directory-entry.js');\r\nvar OpenFileDescription = require('../open-file-description.js');\r\nvar SuperNode = require('../super-node.js');\r\nvar Node = require('../node.js');\r\nvar Stats = require('../stats.js');\r\nvar Buffer = require('../buffer.js');\r\n\r\n/**\r\n * Update node times. Only passed times are modified (undefined times are ignored)\r\n * and filesystem flags are examined in order to override update logic.\r\n */\r\nfunction update_node_times(context, path, node, times, callback) {\r\n // Honour mount flags for how we update times\r\n var flags = context.flags;\r\n if(_(flags).contains(FS_NOCTIME)) {\r\n delete times.ctime;\r\n }\r\n if(_(flags).contains(FS_NOMTIME)) {\r\n delete times.mtime;\r\n }\r\n\r\n // Only do the update if required (i.e., times are still present)\r\n var update = false;\r\n if(times.ctime) {\r\n node.ctime = times.ctime;\r\n // We don't do atime tracking for perf reasons, but do mirror ctime\r\n node.atime = times.ctime;\r\n update = true;\r\n }\r\n if(times.atime) {\r\n // The only time we explicitly pass atime is when utimes(), futimes() is called.\r\n // Override ctime mirror here if so\r\n node.atime = times.atime;\r\n update = true;\r\n }\r\n if(times.mtime) {\r\n node.mtime = times.mtime;\r\n update = true;\r\n }\r\n\r\n function complete(error) {\r\n // Queue this change so we can send watch events.\r\n // Unlike node.js, we send the full path vs. basename/dirname only.\r\n context.changes.push({ event: 'change', path: path });\r\n callback(error);\r\n }\r\n\r\n if(update) {\r\n context.putObject(node.id, node, complete);\r\n } else {\r\n complete();\r\n }\r\n}\r\n\r\n/**\r\n * make_node()\r\n */\r\n// in: file or directory path\r\n// out: new node representing file/directory\r\nfunction make_node(context, path, type, callback) {\r\n if(type !== NODE_TYPE_DIRECTORY && type !== NODE_TYPE_FILE) {\r\n return callback(new Errors.EINVAL('type must be a directory or file', path));\r\n }\r\n\r\n path = normalize(path);\r\n\r\n var name = basename(path);\r\n var parentPath = dirname(path);\r\n var parentNode;\r\n var parentNodeData;\r\n var node;\r\n\r\n // Check if the parent node exists\r\n function create_node_in_parent(error, parentDirectoryNode) {\r\n if(error) {\r\n callback(error);\r\n } else if(parentDirectoryNode.type !== NODE_TYPE_DIRECTORY) {\r\n callback(new Errors.ENOTDIR('a component of the path prefix is not a directory', path));\r\n } else {\r\n parentNode = parentDirectoryNode;\r\n find_node(context, path, check_if_node_exists);\r\n }\r\n }\r\n\r\n // Check if the node to be created already exists\r\n function check_if_node_exists(error, result) {\r\n if(!error && result) {\r\n callback(new Errors.EEXIST('path name already exists', path));\r\n } else if(error && !(error instanceof Errors.ENOENT)) {\r\n callback(error);\r\n } else {\r\n context.getObject(parentNode.data, create_node);\r\n }\r\n }\r\n\r\n // Create the new node\r\n function create_node(error, result) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n parentNodeData = result;\r\n Node.create({\r\n guid: context.guid,\r\n type: type\r\n }, function(error, result) {\r\n if(error) {\r\n callback(error);\r\n return;\r\n }\r\n node = result;\r\n node.nlinks += 1;\r\n context.putObject(node.id, node, update_parent_node_data);\r\n });\r\n }\r\n }\r\n\r\n // Update parent node time\r\n function update_time(error) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n var now = Date.now();\r\n update_node_times(context, parentPath, node, { mtime: now, ctime: now }, callback);\r\n }\r\n }\r\n\r\n // Update the parent nodes data\r\n function update_parent_node_data(error) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n parentNodeData[name] = new DirectoryEntry(node.id, type);\r\n context.putObject(parentNode.data, parentNodeData, update_time);\r\n }\r\n }\r\n\r\n // Find the parent node\r\n find_node(context, parentPath, create_node_in_parent);\r\n}\r\n\r\n/**\r\n * find_node\r\n */\r\n// in: file or directory path\r\n// out: node structure, or error\r\nfunction find_node(context, path, callback) {\r\n path = normalize(path);\r\n if(!path) {\r\n return callback(new Errors.ENOENT('path is an empty string'));\r\n }\r\n var name = basename(path);\r\n var parentPath = dirname(path);\r\n var followedCount = 0;\r\n\r\n function read_root_directory_node(error, superNode) {\r\n if(error) {\r\n callback(error);\r\n } else if(!superNode || superNode.type !== NODE_TYPE_META || !superNode.rnode) {\r\n callback(new Errors.EFILESYSTEMERROR());\r\n } else {\r\n context.getObject(superNode.rnode, check_root_directory_node);\r\n }\r\n }\r\n\r\n function check_root_directory_node(error, rootDirectoryNode) {\r\n if(error) {\r\n callback(error);\r\n } else if(!rootDirectoryNode) {\r\n callback(new Errors.ENOENT());\r\n } else {\r\n callback(null, rootDirectoryNode);\r\n }\r\n }\r\n\r\n // in: parent directory node\r\n // out: parent directory data\r\n function read_parent_directory_data(error, parentDirectoryNode) {\r\n if(error) {\r\n callback(error);\r\n } else if(parentDirectoryNode.type !== NODE_TYPE_DIRECTORY || !parentDirectoryNode.data) {\r\n callback(new Errors.ENOTDIR('a component of the path prefix is not a directory', path));\r\n } else {\r\n context.getObject(parentDirectoryNode.data, get_node_from_parent_directory_data);\r\n }\r\n }\r\n\r\n // in: parent directory data\r\n // out: searched node\r\n function get_node_from_parent_directory_data(error, parentDirectoryData) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n if(!_(parentDirectoryData).has(name)) {\r\n callback(new Errors.ENOENT(null, path));\r\n } else {\r\n var nodeId = parentDirectoryData[name].id;\r\n context.getObject(nodeId, is_symbolic_link);\r\n }\r\n }\r\n }\r\n\r\n function is_symbolic_link(error, node) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n if(node.type === NODE_TYPE_SYMBOLIC_LINK) {\r\n followedCount++;\r\n if(followedCount > SYMLOOP_MAX){\r\n callback(new Errors.ELOOP(null, path));\r\n } else {\r\n follow_symbolic_link(node.data);\r\n }\r\n } else {\r\n callback(null, node);\r\n }\r\n }\r\n }\r\n\r\n function follow_symbolic_link(data) {\r\n data = normalize(data);\r\n parentPath = dirname(data);\r\n name = basename(data);\r\n if(ROOT_DIRECTORY_NAME === name) {\r\n context.getObject(SUPER_NODE_ID, read_root_directory_node);\r\n } else {\r\n find_node(context, parentPath, read_parent_directory_data);\r\n }\r\n }\r\n\r\n if(ROOT_DIRECTORY_NAME === name) {\r\n context.getObject(SUPER_NODE_ID, read_root_directory_node);\r\n } else {\r\n find_node(context, parentPath, read_parent_directory_data);\r\n }\r\n}\r\n\r\n\r\n/**\r\n * set extended attribute (refactor)\r\n */\r\nfunction set_extended_attribute (context, path, node, name, value, flag, callback) {\r\n function update_time(error) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n update_node_times(context, path, node, { ctime: Date.now() }, callback);\r\n }\r\n }\r\n\r\n var xattrs = node.xattrs;\r\n\r\n if (flag === XATTR_CREATE && xattrs.hasOwnProperty(name)) {\r\n callback(new Errors.EEXIST('attribute already exists', path));\r\n }\r\n else if (flag === XATTR_REPLACE && !xattrs.hasOwnProperty(name)) {\r\n callback(new Errors.ENOATTR(null, path));\r\n }\r\n else {\r\n xattrs[name] = value;\r\n context.putObject(node.id, node, update_time);\r\n }\r\n}\r\n\r\n/**\r\n * ensure_root_directory. Creates a root node if necessary.\r\n *\r\n * Note: this should only be invoked when formatting a new file system.\r\n * Multiple invocations of this by separate instances will still result\r\n * in only a single super node.\r\n */\r\nfunction ensure_root_directory(context, callback) {\r\n var superNode;\r\n var directoryNode;\r\n var directoryData;\r\n\r\n function ensure_super_node(error, existingNode) {\r\n if(!error && existingNode) {\r\n // Another instance has beat us and already created the super node.\r\n callback();\r\n } else if(error && !(error instanceof Errors.ENOENT)) {\r\n callback(error);\r\n } else {\r\n SuperNode.create({guid: context.guid}, function(error, result) {\r\n if(error) {\r\n callback(error);\r\n return;\r\n }\r\n superNode = result;\r\n context.putObject(superNode.id, superNode, write_directory_node);\r\n });\r\n }\r\n }\r\n\r\n function write_directory_node(error) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n Node.create({\r\n guid: context.guid,\r\n id: superNode.rnode,\r\n type: NODE_TYPE_DIRECTORY\r\n }, function(error, result) {\r\n if(error) {\r\n callback(error);\r\n return;\r\n }\r\n directoryNode = result;\r\n directoryNode.nlinks += 1;\r\n context.putObject(directoryNode.id, directoryNode, write_directory_data);\r\n });\r\n }\r\n }\r\n\r\n function write_directory_data(error) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n directoryData = {};\r\n context.putObject(directoryNode.data, directoryData, callback);\r\n }\r\n }\r\n\r\n context.getObject(SUPER_NODE_ID, ensure_super_node);\r\n}\r\n\r\n/**\r\n * make_directory\r\n */\r\nfunction make_directory(context, path, callback) {\r\n path = normalize(path);\r\n var name = basename(path);\r\n var parentPath = dirname(path);\r\n\r\n var directoryNode;\r\n var directoryData;\r\n var parentDirectoryNode;\r\n var parentDirectoryData;\r\n\r\n function check_if_directory_exists(error, result) {\r\n if(!error && result) {\r\n callback(new Errors.EEXIST(null, path));\r\n } else if(error && !(error instanceof Errors.ENOENT)) {\r\n callback(error);\r\n } else {\r\n find_node(context, parentPath, read_parent_directory_data);\r\n }\r\n }\r\n\r\n function read_parent_directory_data(error, result) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n parentDirectoryNode = result;\r\n context.getObject(parentDirectoryNode.data, write_directory_node);\r\n }\r\n }\r\n\r\n function write_directory_node(error, result) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n parentDirectoryData = result;\r\n Node.create({\r\n guid: context.guid,\r\n type: NODE_TYPE_DIRECTORY\r\n }, function(error, result) {\r\n if(error) {\r\n callback(error);\r\n return;\r\n }\r\n directoryNode = result;\r\n directoryNode.nlinks += 1;\r\n context.putObject(directoryNode.id, directoryNode, write_directory_data);\r\n });\r\n }\r\n }\r\n\r\n function write_directory_data(error) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n directoryData = {};\r\n context.putObject(directoryNode.data, directoryData, update_parent_directory_data);\r\n }\r\n }\r\n\r\n function update_time(error) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n var now = Date.now();\r\n update_node_times(context, parentPath, parentDirectoryNode, { mtime: now, ctime: now }, callback);\r\n }\r\n }\r\n\r\n function update_parent_directory_data(error) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n parentDirectoryData[name] = new DirectoryEntry(directoryNode.id, NODE_TYPE_DIRECTORY);\r\n context.putObject(parentDirectoryNode.data, parentDirectoryData, update_time);\r\n }\r\n }\r\n\r\n find_node(context, path, check_if_directory_exists);\r\n}\r\n\r\n/**\r\n * remove_directory\r\n */\r\nfunction remove_directory(context, path, callback) {\r\n path = normalize(path);\r\n var name = basename(path);\r\n var parentPath = dirname(path);\r\n\r\n var directoryNode;\r\n var directoryData;\r\n var parentDirectoryNode;\r\n var parentDirectoryData;\r\n\r\n function read_parent_directory_data(error, result) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n parentDirectoryNode = result;\r\n context.getObject(parentDirectoryNode.data, check_if_node_exists);\r\n }\r\n }\r\n\r\n function check_if_node_exists(error, result) {\r\n if(error) {\r\n callback(error);\r\n } else if(ROOT_DIRECTORY_NAME === name) {\r\n callback(new Errors.EBUSY(null, path));\r\n } else if(!_(result).has(name)) {\r\n callback(new Errors.ENOENT(null, path));\r\n } else {\r\n parentDirectoryData = result;\r\n directoryNode = parentDirectoryData[name].id;\r\n context.getObject(directoryNode, check_if_node_is_directory);\r\n }\r\n }\r\n\r\n function check_if_node_is_directory(error, result) {\r\n if(error) {\r\n callback(error);\r\n } else if(result.type !== NODE_TYPE_DIRECTORY) {\r\n callback(new Errors.ENOTDIR(null, path));\r\n } else {\r\n directoryNode = result;\r\n context.getObject(directoryNode.data, check_if_directory_is_empty);\r\n }\r\n }\r\n\r\n function check_if_directory_is_empty(error, result) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n directoryData = result;\r\n if(_(directoryData).size() > 0) {\r\n callback(new Errors.ENOTEMPTY(null, path));\r\n } else {\r\n remove_directory_entry_from_parent_directory_node();\r\n }\r\n }\r\n }\r\n\r\n function update_time(error) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n var now = Date.now();\r\n update_node_times(context, parentPath, parentDirectoryNode, { mtime: now, ctime: now }, remove_directory_node);\r\n }\r\n }\r\n\r\n function remove_directory_entry_from_parent_directory_node() {\r\n delete parentDirectoryData[name];\r\n context.putObject(parentDirectoryNode.data, parentDirectoryData, update_time);\r\n }\r\n\r\n function remove_directory_node(error) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n context.delete(directoryNode.id, remove_directory_data);\r\n }\r\n }\r\n\r\n function remove_directory_data(error) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n context.delete(directoryNode.data, callback);\r\n }\r\n }\r\n\r\n find_node(context, parentPath, read_parent_directory_data);\r\n}\r\n\r\nfunction open_file(context, path, flags, callback) {\r\n path = normalize(path);\r\n var name = basename(path);\r\n var parentPath = dirname(path);\r\n\r\n var directoryNode;\r\n var directoryData;\r\n var directoryEntry;\r\n var fileNode;\r\n var fileData;\r\n\r\n var followedCount = 0;\r\n\r\n if(ROOT_DIRECTORY_NAME === name) {\r\n if(_(flags).contains(O_WRITE)) {\r\n callback(new Errors.EISDIR('the named file is a directory and O_WRITE is set', path));\r\n } else {\r\n find_node(context, path, set_file_node);\r\n }\r\n } else {\r\n find_node(context, parentPath, read_directory_data);\r\n }\r\n\r\n function read_directory_data(error, result) {\r\n if(error) {\r\n callback(error);\r\n } else if(result.type !== NODE_TYPE_DIRECTORY) {\r\n callback(new Errors.ENOENT(null, path));\r\n } else {\r\n directoryNode = result;\r\n context.getObject(directoryNode.data, check_if_file_exists);\r\n }\r\n }\r\n\r\n function check_if_file_exists(error, result) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n directoryData = result;\r\n if(_(directoryData).has(name)) {\r\n if(_(flags).contains(O_EXCLUSIVE)) {\r\n callback(new Errors.ENOENT('O_CREATE and O_EXCLUSIVE are set, and the named file exists', path));\r\n } else {\r\n directoryEntry = directoryData[name];\r\n if(directoryEntry.type === NODE_TYPE_DIRECTORY && _(flags).contains(O_WRITE)) {\r\n callback(new Errors.EISDIR('the named file is a directory and O_WRITE is set', path));\r\n } else {\r\n context.getObject(directoryEntry.id, check_if_symbolic_link);\r\n }\r\n }\r\n } else {\r\n if(!_(flags).contains(O_CREATE)) {\r\n callback(new Errors.ENOENT('O_CREATE is not set and the named file does not exist', path));\r\n } else {\r\n write_file_node();\r\n }\r\n }\r\n }\r\n }\r\n\r\n function check_if_symbolic_link(error, result) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n var node = result;\r\n if(node.type === NODE_TYPE_SYMBOLIC_LINK) {\r\n followedCount++;\r\n if(followedCount > SYMLOOP_MAX){\r\n callback(new Errors.ELOOP(null, path));\r\n } else {\r\n follow_symbolic_link(node.data);\r\n }\r\n } else {\r\n set_file_node(undefined, node);\r\n }\r\n }\r\n }\r\n\r\n function follow_symbolic_link(data) {\r\n data = normalize(data);\r\n parentPath = dirname(data);\r\n name = basename(data);\r\n if(ROOT_DIRECTORY_NAME === name) {\r\n if(_(flags).contains(O_WRITE)) {\r\n callback(new Errors.EISDIR('the named file is a directory and O_WRITE is set', path));\r\n } else {\r\n find_node(context, path, set_file_node);\r\n }\r\n }\r\n find_node(context, parentPath, read_directory_data);\r\n }\r\n\r\n function set_file_node(error, result) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n fileNode = result;\r\n callback(null, fileNode);\r\n }\r\n }\r\n\r\n function write_file_node() {\r\n Node.create({\r\n guid: context.guid,\r\n type: NODE_TYPE_FILE\r\n }, function(error, result) {\r\n if(error) {\r\n callback(error);\r\n return;\r\n }\r\n fileNode = result;\r\n fileNode.nlinks += 1;\r\n context.putObject(fileNode.id, fileNode, write_file_data);\r\n });\r\n }\r\n\r\n function write_file_data(error) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n fileData = new Buffer(0);\r\n fileData.fill(0);\r\n context.putBuffer(fileNode.data, fileData, update_directory_data);\r\n }\r\n }\r\n\r\n function update_time(error) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n var now = Date.now();\r\n update_node_times(context, parentPath, directoryNode, { mtime: now, ctime: now }, handle_update_result);\r\n }\r\n }\r\n\r\n function update_directory_data(error) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n directoryData[name] = new DirectoryEntry(fileNode.id, NODE_TYPE_FILE);\r\n context.putObject(directoryNode.data, directoryData, update_time);\r\n }\r\n }\r\n\r\n function handle_update_result(error) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n callback(null, fileNode);\r\n }\r\n }\r\n}\r\n\r\nfunction replace_data(context, ofd, buffer, offset, length, callback) {\r\n var fileNode;\r\n\r\n function return_nbytes(error) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n callback(null, length);\r\n }\r\n }\r\n\r\n function update_time(error) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n var now = Date.now();\r\n update_node_times(context, ofd.path, fileNode, { mtime: now, ctime: now }, return_nbytes);\r\n }\r\n }\r\n\r\n function update_file_node(error) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n context.putObject(fileNode.id, fileNode, update_time);\r\n }\r\n }\r\n\r\n function write_file_data(error, result) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n fileNode = result;\r\n var newData = new Buffer(length);\r\n newData.fill(0);\r\n buffer.copy(newData, 0, offset, offset + length);\r\n ofd.position = length;\r\n\r\n fileNode.size = length;\r\n fileNode.version += 1;\r\n\r\n context.putBuffer(fileNode.data, newData, update_file_node);\r\n }\r\n }\r\n\r\n context.getObject(ofd.id, write_file_data);\r\n}\r\n\r\nfunction write_data(context, ofd, buffer, offset, length, position, callback) {\r\n var fileNode;\r\n var fileData;\r\n\r\n function return_nbytes(error) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n callback(null, length);\r\n }\r\n }\r\n\r\n function update_time(error) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n var now = Date.now();\r\n update_node_times(context, ofd.path, fileNode, { mtime: now, ctime: now }, return_nbytes);\r\n }\r\n }\r\n\r\n function update_file_node(error) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n context.putObject(fileNode.id, fileNode, update_time);\r\n }\r\n }\r\n\r\n function update_file_data(error, result) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n fileData = result;\r\n if(!fileData) {\r\n return callback(new Errors.EIO('Expected Buffer'));\r\n }\r\n var _position = (!(undefined === position || null === position)) ? position : ofd.position;\r\n var newSize = Math.max(fileData.length, _position + length);\r\n var newData = new Buffer(newSize);\r\n newData.fill(0);\r\n if(fileData) {\r\n fileData.copy(newData);\r\n }\r\n buffer.copy(newData, _position, offset, offset + length);\r\n if(undefined === position) {\r\n ofd.position += length;\r\n }\r\n\r\n fileNode.size = newSize;\r\n fileNode.version += 1;\r\n\r\n context.putBuffer(fileNode.data, newData, update_file_node);\r\n }\r\n }\r\n\r\n function read_file_data(error, result) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n fileNode = result;\r\n context.getBuffer(fileNode.data, update_file_data);\r\n }\r\n }\r\n\r\n context.getObject(ofd.id, read_file_data);\r\n}\r\n\r\nfunction read_data(context, ofd, buffer, offset, length, position, callback) {\r\n var fileNode;\r\n var fileData;\r\n\r\n function handle_file_data(error, result) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n fileData = result;\r\n if(!fileData) {\r\n return callback(new Errors.EIO('Expected Buffer'));\r\n }\r\n var _position = (!(undefined === position || null === position)) ? position : ofd.position;\r\n length = (_position + length > buffer.length) ? length - _position : length;\r\n fileData.copy(buffer, offset, _position, _position + length);\r\n if(undefined === position) {\r\n ofd.position += length;\r\n }\r\n callback(null, length);\r\n }\r\n }\r\n\r\n function read_file_data(error, result) {\r\n if(error) {\r\n callback(error);\r\n } else if(result.type === NODE_TYPE_DIRECTORY) {\r\n callback(new Errors.EISDIR('the named file is a directory', ofd.path));\r\n } else {\r\n fileNode = result;\r\n context.getBuffer(fileNode.data, handle_file_data);\r\n }\r\n }\r\n\r\n context.getObject(ofd.id, read_file_data);\r\n}\r\n\r\nfunction stat_file(context, path, callback) {\r\n path = normalize(path);\r\n find_node(context, path, callback);\r\n}\r\n\r\nfunction fstat_file(context, ofd, callback) {\r\n ofd.getNode(context, callback);\r\n}\r\n\r\nfunction lstat_file(context, path, callback) {\r\n path = normalize(path);\r\n var name = basename(path);\r\n var parentPath = dirname(path);\r\n\r\n var directoryNode;\r\n var directoryData;\r\n\r\n if(ROOT_DIRECTORY_NAME === name) {\r\n find_node(context, path, callback);\r\n } else {\r\n find_node(context, parentPath, read_directory_data);\r\n }\r\n\r\n function read_directory_data(error, result) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n directoryNode = result;\r\n context.getObject(directoryNode.data, check_if_file_exists);\r\n }\r\n }\r\n\r\n function check_if_file_exists(error, result) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n directoryData = result;\r\n if(!_(directoryData).has(name)) {\r\n callback(new Errors.ENOENT('a component of the path does not name an existing file', path));\r\n } else {\r\n context.getObject(directoryData[name].id, callback);\r\n }\r\n }\r\n }\r\n}\r\n\r\nfunction link_node(context, oldpath, newpath, callback) {\r\n oldpath = normalize(oldpath);\r\n var oldname = basename(oldpath);\r\n var oldParentPath = dirname(oldpath);\r\n\r\n newpath = normalize(newpath);\r\n var newname = basename(newpath);\r\n var newParentPath = dirname(newpath);\r\n var ctime = Date.now();\r\n\r\n var oldDirectoryNode;\r\n var oldDirectoryData;\r\n var newDirectoryNode;\r\n var newDirectoryData;\r\n var fileNodeID;\r\n var fileNode;\r\n\r\n function update_time(error) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n update_node_times(context, newpath, fileNode, { ctime: ctime }, callback);\r\n }\r\n }\r\n\r\n function update_file_node(error, result) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n fileNode = result;\r\n fileNode.nlinks += 1;\r\n context.putObject(fileNode.id, fileNode, update_time);\r\n }\r\n }\r\n\r\n function read_file_node(error) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n context.getObject(fileNodeID, update_file_node);\r\n }\r\n }\r\n\r\n function check_if_new_file_exists(error, result) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n newDirectoryData = result;\r\n if(_(newDirectoryData).has(newname)) {\r\n callback(new Errors.EEXIST('newpath resolves to an existing file', newname));\r\n } else {\r\n newDirectoryData[newname] = oldDirectoryData[oldname];\r\n fileNodeID = newDirectoryData[newname].id;\r\n context.putObject(newDirectoryNode.data, newDirectoryData, read_file_node);\r\n }\r\n }\r\n }\r\n\r\n function read_new_directory_data(error, result) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n newDirectoryNode = result;\r\n context.getObject(newDirectoryNode.data, check_if_new_file_exists);\r\n }\r\n }\r\n\r\n function check_if_old_file_exists(error, result) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n oldDirectoryData = result;\r\n if(!_(oldDirectoryData).has(oldname)) {\r\n callback(new Errors.ENOENT('a component of either path prefix does not exist', oldname));\r\n } else if(oldDirectoryData[oldname].type === NODE_TYPE_DIRECTORY) {\r\n callback(new Errors.EPERM('oldpath refers to a directory'));\r\n } else {\r\n find_node(context, newParentPath, read_new_directory_data);\r\n }\r\n }\r\n }\r\n\r\n function read_old_directory_data(error, result) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n oldDirectoryNode = result;\r\n context.getObject(oldDirectoryNode.data, check_if_old_file_exists);\r\n }\r\n }\r\n\r\n find_node(context, oldParentPath, read_old_directory_data);\r\n}\r\n\r\nfunction unlink_node(context, path, callback) {\r\n path = normalize(path);\r\n var name = basename(path);\r\n var parentPath = dirname(path);\r\n\r\n var directoryNode;\r\n var directoryData;\r\n var fileNode;\r\n\r\n function update_directory_data(error) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n delete directoryData[name];\r\n context.putObject(directoryNode.data, directoryData, function(error) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n var now = Date.now();\r\n update_node_times(context, parentPath, directoryNode, { mtime: now, ctime: now }, callback);\r\n }\r\n });\r\n }\r\n }\r\n\r\n function delete_file_data(error) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n context.delete(fileNode.data, update_directory_data);\r\n }\r\n }\r\n\r\n function update_file_node(error, result) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n fileNode = result;\r\n fileNode.nlinks -= 1;\r\n if(fileNode.nlinks < 1) {\r\n context.delete(fileNode.id, delete_file_data);\r\n } else {\r\n context.putObject(fileNode.id, fileNode, function(error) {\r\n if(error) {\r\n callback(error);\r\n } else { \r\n update_node_times(context, path, fileNode, { ctime: Date.now() }, update_directory_data);\r\n }\r\n });\r\n }\r\n }\r\n }\r\n\r\n function check_if_node_is_directory(error, result) {\r\n if(error) {\r\n callback(error);\r\n } else if(result.type === NODE_TYPE_DIRECTORY) {\r\n callback(new Errors.EPERM('unlink not permitted on directories', name));\r\n } else {\r\n update_file_node(null, result);\r\n }\r\n }\r\n\r\n function check_if_file_exists(error, result) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n directoryData = result;\r\n if(!_(directoryData).has(name)) {\r\n callback(new Errors.ENOENT('a component of the path does not name an existing file', name));\r\n } else {\r\n context.getObject(directoryData[name].id, check_if_node_is_directory);\r\n }\r\n }\r\n }\r\n\r\n function read_directory_data(error, result) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n directoryNode = result;\r\n context.getObject(directoryNode.data, check_if_file_exists);\r\n }\r\n }\r\n\r\n find_node(context, parentPath, read_directory_data);\r\n}\r\n\r\nfunction read_directory(context, path, callback) {\r\n path = normalize(path);\r\n\r\n var directoryNode;\r\n var directoryData;\r\n\r\n function handle_directory_data(error, result) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n directoryData = result;\r\n var files = Object.keys(directoryData);\r\n callback(null, files);\r\n }\r\n }\r\n\r\n function read_directory_data(error, result) {\r\n if(error) {\r\n callback(error);\r\n } else if(result.type !== NODE_TYPE_DIRECTORY) {\r\n callback(new Errors.ENOTDIR(null, path));\r\n } else {\r\n directoryNode = result;\r\n context.getObject(directoryNode.data, handle_directory_data);\r\n }\r\n }\r\n\r\n find_node(context, path, read_directory_data);\r\n}\r\n\r\nfunction make_symbolic_link(context, srcpath, dstpath, callback) {\r\n dstpath = normalize(dstpath);\r\n var name = basename(dstpath);\r\n var parentPath = dirname(dstpath);\r\n\r\n var directoryNode;\r\n var directoryData;\r\n var fileNode;\r\n\r\n if(ROOT_DIRECTORY_NAME === name) {\r\n callback(new Errors.EEXIST(null, name));\r\n } else {\r\n find_node(context, parentPath, read_directory_data);\r\n }\r\n\r\n function read_directory_data(error, result) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n directoryNode = result;\r\n context.getObject(directoryNode.data, check_if_file_exists);\r\n }\r\n }\r\n\r\n function check_if_file_exists(error, result) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n directoryData = result;\r\n if(_(directoryData).has(name)) {\r\n callback(new Errors.EEXIST(null, name));\r\n } else {\r\n write_file_node();\r\n }\r\n }\r\n }\r\n\r\n function write_file_node() {\r\n Node.create({\r\n guid: context.guid,\r\n type: NODE_TYPE_SYMBOLIC_LINK\r\n }, function(error, result) {\r\n if(error) {\r\n callback(error);\r\n return;\r\n }\r\n fileNode = result;\r\n fileNode.nlinks += 1;\r\n\r\n // If the srcpath isn't absolute, resolve it relative to the dstpath\r\n // but store both versions, since we'll use the relative one in readlink().\r\n if(!isAbsolutePath(srcpath)) {\r\n fileNode.symlink_relpath = srcpath;\r\n srcpath = Path.resolve(parentPath, srcpath); \r\n }\r\n\r\n fileNode.size = srcpath.length;\r\n fileNode.data = srcpath;\r\n \r\n context.putObject(fileNode.id, fileNode, update_directory_data);\r\n });\r\n }\r\n\r\n function update_time(error) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n var now = Date.now();\r\n update_node_times(context, parentPath, directoryNode, { mtime: now, ctime: now }, callback);\r\n }\r\n }\r\n\r\n function update_directory_data(error) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n directoryData[name] = new DirectoryEntry(fileNode.id, NODE_TYPE_SYMBOLIC_LINK);\r\n context.putObject(directoryNode.data, directoryData, update_time);\r\n }\r\n }\r\n}\r\n\r\nfunction read_link(context, path, callback) {\r\n path = normalize(path);\r\n var name = basename(path);\r\n var parentPath = dirname(path);\r\n\r\n var directoryNode;\r\n var directoryData;\r\n\r\n find_node(context, parentPath, read_directory_data);\r\n\r\n function read_directory_data(error, result) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n directoryNode = result;\r\n context.getObject(directoryNode.data, check_if_file_exists);\r\n }\r\n }\r\n\r\n function check_if_file_exists(error, result) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n directoryData = result;\r\n if(!_(directoryData).has(name)) {\r\n callback(new Errors.ENOENT('a component of the path does not name an existing file', name));\r\n } else {\r\n context.getObject(directoryData[name].id, check_if_symbolic);\r\n }\r\n }\r\n }\r\n\r\n function check_if_symbolic(error, fileNode) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n if(fileNode.type !== NODE_TYPE_SYMBOLIC_LINK) {\r\n callback(new Errors.EINVAL('path not a symbolic link', path));\r\n } else {\r\n // If we were originally given a relative path, return that now vs. the\r\n // absolute path we've generated and use elsewhere internally.\r\n var target = fileNode.symlink_relpath ? fileNode.symlink_relpath : fileNode.data;\r\n callback(null, target);\r\n }\r\n }\r\n }\r\n}\r\n\r\nfunction truncate_file(context, path, length, callback) {\r\n path = normalize(path);\r\n\r\n var fileNode;\r\n\r\n function read_file_data (error, node) {\r\n if (error) {\r\n callback(error);\r\n } else if(node.type === NODE_TYPE_DIRECTORY ) {\r\n callback(new Errors.EISDIR(null, path));\r\n } else{\r\n fileNode = node;\r\n context.getBuffer(fileNode.data, truncate_file_data);\r\n }\r\n }\r\n\r\n function truncate_file_data(error, fileData) {\r\n if (error) {\r\n callback(error);\r\n } else {\r\n if(!fileData) {\r\n return callback(new Errors.EIO('Expected Buffer'));\r\n }\r\n var data = new Buffer(length);\r\n data.fill(0);\r\n if(fileData) {\r\n fileData.copy(data);\r\n }\r\n context.putBuffer(fileNode.data, data, update_file_node);\r\n }\r\n }\r\n\r\n function update_time(error) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n var now = Date.now();\r\n update_node_times(context, path, fileNode, { mtime: now, ctime: now }, callback);\r\n }\r\n }\r\n\r\n function update_file_node (error) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n fileNode.size = length;\r\n fileNode.version += 1;\r\n context.putObject(fileNode.id, fileNode, update_time);\r\n }\r\n }\r\n\r\n if(length < 0) {\r\n callback(new Errors.EINVAL('length cannot be negative'));\r\n } else {\r\n find_node(context, path, read_file_data);\r\n }\r\n}\r\n\r\nfunction ftruncate_file(context, ofd, length, callback) {\r\n var fileNode;\r\n\r\n function read_file_data (error, node) {\r\n if (error) {\r\n callback(error);\r\n } else if(node.type === NODE_TYPE_DIRECTORY ) {\r\n callback(new Errors.EISDIR());\r\n } else{\r\n fileNode = node;\r\n context.getBuffer(fileNode.data, truncate_file_data);\r\n }\r\n }\r\n\r\n function truncate_file_data(error, fileData) {\r\n if (error) {\r\n callback(error);\r\n } else {\r\n var data;\r\n if(!fileData) {\r\n return callback(new Errors.EIO('Expected Buffer'));\r\n }\r\n if(fileData) {\r\n data = fileData.slice(0, length);\r\n } else {\r\n data = new Buffer(length);\r\n data.fill(0);\r\n }\r\n context.putBuffer(fileNode.data, data, update_file_node);\r\n }\r\n }\r\n\r\n function update_time(error) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n var now = Date.now();\r\n update_node_times(context, ofd.path, fileNode, { mtime: now, ctime: now }, callback);\r\n }\r\n }\r\n\r\n function update_file_node (error) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n fileNode.size = length;\r\n fileNode.version += 1;\r\n context.putObject(fileNode.id, fileNode, update_time);\r\n }\r\n }\r\n\r\n if(length < 0) {\r\n callback(new Errors.EINVAL('length cannot be negative'));\r\n } else {\r\n ofd.getNode(context, read_file_data);\r\n }\r\n}\r\n\r\nfunction utimes_file(context, path, atime, mtime, callback) {\r\n path = normalize(path);\r\n\r\n function update_times(error, node) {\r\n if (error) {\r\n callback(error);\r\n } else {\r\n update_node_times(context, path, node, { atime: atime, ctime: mtime, mtime: mtime }, callback);\r\n }\r\n }\r\n\r\n if (typeof atime !== 'number' || typeof mtime !== 'number') {\r\n callback(new Errors.EINVAL('atime and mtime must be number', path));\r\n }\r\n else if (atime < 0 || mtime < 0) {\r\n callback(new Errors.EINVAL('atime and mtime must be positive integers', path));\r\n }\r\n else {\r\n find_node(context, path, update_times);\r\n }\r\n}\r\n\r\nfunction futimes_file(context, ofd, atime, mtime, callback) {\r\n\r\n function update_times (error, node) {\r\n if (error) {\r\n callback(error);\r\n } else {\r\n update_node_times(context, ofd.path, node, { atime: atime, ctime: mtime, mtime: mtime }, callback);\r\n }\r\n }\r\n\r\n if (typeof atime !== 'number' || typeof mtime !== 'number') {\r\n callback(new Errors.EINVAL('atime and mtime must be a number'));\r\n }\r\n else if (atime < 0 || mtime < 0) {\r\n callback(new Errors.EINVAL('atime and mtime must be positive integers'));\r\n }\r\n else {\r\n ofd.getNode(context, update_times);\r\n }\r\n}\r\n\r\nfunction setxattr_file(context, path, name, value, flag, callback) {\r\n path = normalize(path);\r\n\r\n function setxattr(error, node) {\r\n if(error) {\r\n return callback(error);\r\n }\r\n set_extended_attribute(context, path, node, name, value, flag, callback);\r\n }\r\n\r\n if (typeof name !== 'string') {\r\n callback(new Errors.EINVAL('attribute name must be a string', path));\r\n }\r\n else if (!name) {\r\n callback(new Errors.EINVAL('attribute name cannot be an empty string', path));\r\n }\r\n else if (flag !== null &&\r\n flag !== XATTR_CREATE && flag !== XATTR_REPLACE) {\r\n callback(new Errors.EINVAL('invalid flag, must be null, XATTR_CREATE or XATTR_REPLACE', path));\r\n }\r\n else {\r\n find_node(context, path, setxattr);\r\n }\r\n}\r\n\r\nfunction fsetxattr_file (context, ofd, name, value, flag, callback) {\r\n function setxattr(error, node) {\r\n if(error) {\r\n return callback(error);\r\n }\r\n set_extended_attribute(context, ofd.path, node, name, value, flag, callback);\r\n }\r\n\r\n if (typeof name !== 'string') {\r\n callback(new Errors.EINVAL('attribute name must be a string'));\r\n }\r\n else if (!name) {\r\n callback(new Errors.EINVAL('attribute name cannot be an empty string'));\r\n }\r\n else if (flag !== null &&\r\n flag !== XATTR_CREATE && flag !== XATTR_REPLACE) {\r\n callback(new Errors.EINVAL('invalid flag, must be null, XATTR_CREATE or XATTR_REPLACE'));\r\n }\r\n else {\r\n ofd.getNode(context, setxattr);\r\n }\r\n}\r\n\r\nfunction getxattr_file (context, path, name, callback) {\r\n path = normalize(path);\r\n\r\n function get_xattr(error, node) {\r\n if(error) {\r\n return callback(error);\r\n }\r\n\r\n var xattrs = node.xattrs;\r\n\r\n if (!xattrs.hasOwnProperty(name)) {\r\n callback(new Errors.ENOATTR(null, path));\r\n }\r\n else {\r\n callback(null, xattrs[name]);\r\n }\r\n }\r\n\r\n if (typeof name !== 'string') {\r\n callback(new Errors.EINVAL('attribute name must be a string', path));\r\n }\r\n else if (!name) {\r\n callback(new Errors.EINVAL('attribute name cannot be an empty string', path));\r\n }\r\n else {\r\n find_node(context, path, get_xattr);\r\n }\r\n}\r\n\r\nfunction fgetxattr_file (context, ofd, name, callback) {\r\n\r\n function get_xattr (error, node) {\r\n if (error) {\r\n return callback(error);\r\n }\r\n\r\n var xattrs = node.xattrs;\r\n\r\n if (!xattrs.hasOwnProperty(name)) {\r\n callback(new Errors.ENOATTR());\r\n }\r\n else {\r\n callback(null, xattrs[name]);\r\n }\r\n }\r\n\r\n if (typeof name !== 'string') {\r\n callback(new Errors.EINVAL());\r\n }\r\n else if (!name) {\r\n callback(new Errors.EINVAL('attribute name cannot be an empty string'));\r\n }\r\n else {\r\n ofd.getNode(context, get_xattr);\r\n }\r\n}\r\n\r\nfunction removexattr_file (context, path, name, callback) {\r\n path = normalize(path);\r\n\r\n function remove_xattr (error, node) {\r\n if (error) {\r\n return callback(error);\r\n }\r\n\r\n function update_time(error) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n update_node_times(context, path, node, { ctime: Date.now() }, callback);\r\n }\r\n }\r\n\r\n var xattrs = node.xattrs;\r\n\r\n if (!xattrs.hasOwnProperty(name)) {\r\n callback(new Errors.ENOATTR(null, path));\r\n }\r\n else {\r\n delete xattrs[name];\r\n context.putObject(node.id, node, update_time);\r\n }\r\n }\r\n\r\n if (typeof name !== 'string') {\r\n callback(new Errors.EINVAL('attribute name must be a string', path));\r\n }\r\n else if (!name) {\r\n callback(new Errors.EINVAL('attribute name cannot be an empty string', path));\r\n }\r\n else {\r\n find_node(context, path, remove_xattr);\r\n }\r\n}\r\n\r\nfunction fremovexattr_file (context, ofd, name, callback) {\r\n\r\n function remove_xattr (error, node) {\r\n if (error) {\r\n return callback(error);\r\n }\r\n\r\n function update_time(error) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n update_node_times(context, ofd.path, node, { ctime: Date.now() }, callback);\r\n }\r\n }\r\n\r\n var xattrs = node.xattrs;\r\n\r\n if (!xattrs.hasOwnProperty(name)) {\r\n callback(new Errors.ENOATTR());\r\n }\r\n else {\r\n delete xattrs[name];\r\n context.putObject(node.id, node, update_time);\r\n }\r\n }\r\n\r\n if (typeof name !== 'string') {\r\n callback(new Errors.EINVAL('attribute name must be a string'));\r\n }\r\n else if (!name) {\r\n callback(new Errors.EINVAL('attribute name cannot be an empty string'));\r\n }\r\n else {\r\n ofd.getNode(context, remove_xattr);\r\n }\r\n}\r\n\r\nfunction validate_flags(flags) {\r\n if(!_(O_FLAGS).has(flags)) {\r\n return null;\r\n }\r\n return O_FLAGS[flags];\r\n}\r\n\r\nfunction validate_file_options(options, enc, fileMode){\r\n if(!options) {\r\n options = { encoding: enc, flag: fileMode };\r\n } else if(typeof options === 'function') {\r\n options = { encoding: enc, flag: fileMode };\r\n } else if(typeof options === 'string') {\r\n options = { encoding: options, flag: fileMode };\r\n }\r\n return options;\r\n}\r\n\r\nfunction pathCheck(path, allowRelative, callback) {\r\n var err;\r\n\r\n if(typeof allowRelative === 'function') {\r\n callback = allowRelative;\r\n allowRelative = false;\r\n }\r\n\r\n if(!path) {\r\n err = new Errors.EINVAL('Path must be a string', path);\r\n } else if(isNullPath(path)) {\r\n err = new Errors.EINVAL('Path must be a string without null bytes.', path);\r\n } else if(!allowRelative && !isAbsolutePath(path)) {\r\n err = new Errors.EINVAL('Path must be absolute.', path);\r\n }\r\n\r\n if(err) {\r\n callback(err);\r\n return false;\r\n }\r\n return true;\r\n}\r\n\r\n\r\nfunction open(fs, context, path, flags, mode, callback) {\r\n /**\r\n * NOTE: we support the same signature as node with a `mode` arg,\r\n * but ignore it. We need to add it. Here is what node.js does:\r\n * function open(path, flags, mode, callback) {\r\n * path = getPathFromURL(path);\r\n * validatePath(path);\r\n * const flagsNumber = stringToFlags(flags);\r\n * if (arguments.length < 4) {\r\n * callback = makeCallback(mode);\r\n * mode = 0o666;\r\n * } else {\r\n * mode = validateAndMaskMode(mode, 'mode', 0o666);\r\n * callback = makeCallback(callback);\r\n * }\r\n */\r\n\r\n callback = arguments[arguments.length - 1];\r\n if(!pathCheck(path, callback)) return;\r\n\r\n function check_result(error, fileNode) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n var position;\r\n if(_(flags).contains(O_APPEND)) {\r\n position = fileNode.size;\r\n } else {\r\n position = 0;\r\n }\r\n var openFileDescription = new OpenFileDescription(path, fileNode.id, flags, position);\r\n var fd = fs.allocDescriptor(openFileDescription);\r\n callback(null, fd);\r\n }\r\n }\r\n\r\n flags = validate_flags(flags);\r\n if(!flags) {\r\n callback(new Errors.EINVAL('flags is not valid'), path);\r\n }\r\n\r\n open_file(context, path, flags, check_result);\r\n}\r\n\r\nfunction close(fs, context, fd, callback) {\r\n if(!_(fs.openFiles).has(fd)) {\r\n callback(new Errors.EBADF());\r\n } else {\r\n fs.releaseDescriptor(fd);\r\n callback(null);\r\n }\r\n}\r\n\r\nfunction mknod(fs, context, path, type, callback) {\r\n if(!pathCheck(path, callback)) return;\r\n make_node(context, path, type, callback);\r\n}\r\n\r\nfunction mkdir(fs, context, path, mode, callback) {\r\n if (arguments.length < 5) {\r\n callback = mode;\r\n mode = FULL_READ_WRITE_EXEC_PERMISSIONS;\r\n } else {\r\n mode = validateAndMaskMode(mode, FULL_READ_WRITE_EXEC_PERMISSIONS, callback);\r\n if(!mode) return;\r\n }\r\n \r\n if(!pathCheck(path, callback)) return;\r\n make_directory(context, path, callback);\r\n}\r\n\r\nfunction rmdir(fs, context, path, callback) {\r\n if(!pathCheck(path, callback)) return;\r\n remove_directory(context, path, callback);\r\n}\r\n\r\nfunction stat(fs, context, path, callback) {\r\n if(!pathCheck(path, callback)) return;\r\n\r\n function check_result(error, result) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n var stats = new Stats(path, result, fs.name);\r\n callback(null, stats);\r\n }\r\n }\r\n\r\n stat_file(context, path, check_result);\r\n}\r\n\r\nfunction fstat(fs, context, fd, callback) {\r\n function check_result(error, result) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n var stats = new Stats(ofd.path, result, fs.name);\r\n callback(null, stats);\r\n }\r\n }\r\n\r\n var ofd = fs.openFiles[fd];\r\n if(!ofd) {\r\n callback(new Errors.EBADF());\r\n } else {\r\n fstat_file(context, ofd, check_result);\r\n }\r\n}\r\n\r\nfunction link(fs, context, oldpath, newpath, callback) {\r\n if(!pathCheck(oldpath, callback)) return;\r\n if(!pathCheck(newpath, callback)) return;\r\n link_node(context, oldpath, newpath, callback);\r\n}\r\n\r\nfunction unlink(fs, context, path, callback) {\r\n if(!pathCheck(path, callback)) return;\r\n unlink_node(context, path, callback);\r\n}\r\n\r\nfunction read(fs, context, fd, buffer, offset, length, position, callback) {\r\n // Follow how node.js does this\r\n function wrapped_cb(err, bytesRead) {\r\n // Retain a reference to buffer so that it can't be GC'ed too soon.\r\n callback(err, bytesRead || 0, buffer);\r\n }\r\n\r\n offset = (undefined === offset) ? 0 : offset;\r\n length = (undefined === length) ? buffer.length - offset : length;\r\n callback = arguments[arguments.length - 1];\r\n\r\n var ofd = fs.openFiles[fd];\r\n if(!ofd) {\r\n callback(new Errors.EBADF());\r\n } else if(!_(ofd.flags).contains(O_READ)) {\r\n callback(new Errors.EBADF('descriptor does not permit reading'));\r\n } else {\r\n read_data(context, ofd, buffer, offset, length, position, wrapped_cb);\r\n }\r\n}\r\n\r\nfunction readFile(fs, context, path, options, callback) {\r\n callback = arguments[arguments.length - 1];\r\n options = validate_file_options(options, null, 'r');\r\n\r\n if(!pathCheck(path, callback)) return;\r\n\r\n var flags = validate_flags(options.flag || 'r');\r\n if(!flags) {\r\n return callback(new Errors.EINVAL('flags is not valid', path));\r\n }\r\n\r\n open_file(context, path, flags, function(err, fileNode) {\r\n if(err) {\r\n return callback(err);\r\n }\r\n var ofd = new OpenFileDescription(path, fileNode.id, flags, 0);\r\n var fd = fs.allocDescriptor(ofd);\r\n\r\n function cleanup() {\r\n fs.releaseDescriptor(fd);\r\n }\r\n\r\n fstat_file(context, ofd, function(err, fstatResult) {\r\n if(err) {\r\n cleanup();\r\n return callback(err);\r\n }\r\n\r\n var stats = new Stats(ofd.path, fstatResult, fs.name);\r\n\r\n if(stats.isDirectory()) {\r\n cleanup();\r\n return callback(new Errors.EISDIR('illegal operation on directory', path));\r\n }\r\n\r\n var size = stats.size;\r\n var buffer = new Buffer(size);\r\n buffer.fill(0);\r\n\r\n read_data(context, ofd, buffer, 0, size, 0, function(err) {\r\n cleanup();\r\n\r\n if(err) {\r\n return callback(err);\r\n }\r\n\r\n var data;\r\n if(options.encoding === 'utf8') {\r\n data = Encoding.decode(buffer);\r\n } else {\r\n data = buffer;\r\n }\r\n callback(null, data);\r\n });\r\n });\r\n });\r\n}\r\n\r\nfunction write(fs, context, fd, buffer, offset, length, position, callback) {\r\n callback = arguments[arguments.length - 1];\r\n offset = (undefined === offset) ? 0 : offset;\r\n length = (undefined === length) ? buffer.length - offset : length;\r\n\r\n var ofd = fs.openFiles[fd];\r\n if(!ofd) {\r\n callback(new Errors.EBADF());\r\n } else if(!_(ofd.flags).contains(O_WRITE)) {\r\n callback(new Errors.EBADF('descriptor does not permit writing'));\r\n } else if(buffer.length - offset < length) {\r\n callback(new Errors.EIO('intput buffer is too small'));\r\n } else {\r\n write_data(context, ofd, buffer, offset, length, position, callback);\r\n }\r\n}\r\n\r\nfunction writeFile(fs, context, path, data, options, callback) {\r\n callback = arguments[arguments.length - 1];\r\n options = validate_file_options(options, 'utf8', 'w');\r\n\r\n if(!pathCheck(path, callback)) return;\r\n\r\n var flags = validate_flags(options.flag || 'w');\r\n if(!flags) {\r\n return callback(new Errors.EINVAL('flags is not valid', path));\r\n }\r\n\r\n data = data || '';\r\n if(typeof data === 'number') {\r\n data = '' + data;\r\n }\r\n if(typeof data === 'string' && options.encoding === 'utf8') {\r\n data = Encoding.encode(data);\r\n }\r\n\r\n open_file(context, path, flags, function(err, fileNode) {\r\n if(err) {\r\n return callback(err);\r\n }\r\n var ofd = new OpenFileDescription(path, fileNode.id, flags, 0);\r\n var fd = fs.allocDescriptor(ofd);\r\n\r\n replace_data(context, ofd, data, 0, data.length, function(err) {\r\n fs.releaseDescriptor(fd);\r\n\r\n if(err) {\r\n return callback(err);\r\n }\r\n callback(null);\r\n });\r\n });\r\n}\r\n\r\nfunction appendFile(fs, context, path, data, options, callback) {\r\n callback = arguments[arguments.length - 1];\r\n options = validate_file_options(options, 'utf8', 'a');\r\n\r\n if(!pathCheck(path, callback)) return;\r\n\r\n var flags = validate_flags(options.flag || 'a');\r\n if(!flags) {\r\n return callback(new Errors.EINVAL('flags is not valid', path));\r\n }\r\n\r\n data = data || '';\r\n if(typeof data === 'number') {\r\n data = '' + data;\r\n }\r\n if(typeof data === 'string' && options.encoding === 'utf8') {\r\n data = Encoding.encode(data);\r\n }\r\n\r\n open_file(context, path, flags, function(err, fileNode) {\r\n if(err) {\r\n return callback(err);\r\n }\r\n var ofd = new OpenFileDescription(path, fileNode.id, flags, fileNode.size);\r\n var fd = fs.allocDescriptor(ofd);\r\n\r\n write_data(context, ofd, data, 0, data.length, ofd.position, function(err) {\r\n fs.releaseDescriptor(fd);\r\n\r\n if(err) {\r\n return callback(err);\r\n }\r\n callback(null);\r\n });\r\n });\r\n}\r\n\r\nfunction exists(fs, context, path, callback) {\r\n function cb(err) {\r\n callback(err ? false : true);\r\n }\r\n console.warn('This method is deprecated. For more details see https://nodejs.org/api/fs.html#fs_fs_exists_path_callback');// eslint-disable-line no-console\r\n stat(fs, context, path, cb);\r\n}\r\n\r\n// Based on https://github.com/nodejs/node/blob/c700cc42da9cf73af9fec2098520a6c0a631d901/lib/internal/validators.js#L21\r\nvar octalReg = /^[0-7]+$/;\r\nfunction isUint32(value) {\r\n return value === (value >>> 0);\r\n}\r\n// Validator for mode_t (the S_* constants). Valid numbers or octal strings\r\n// will be masked with 0o777 to be consistent with the behavior in POSIX APIs.\r\nfunction validateAndMaskMode(value, def, callback) {\r\n if(typeof def === 'function') {\r\n callback = def;\r\n def = undefined;\r\n }\r\n\r\n if (isUint32(value)) {\r\n return value & FULL_READ_WRITE_EXEC_PERMISSIONS;\r\n }\r\n\r\n if (typeof value === 'number') {\r\n if (!Number.isInteger(value)) {\r\n callback(new Errors.EINVAL('mode not a valid an integer value', value));\r\n return false;\r\n } else {\r\n // 2 ** 32 === 4294967296\r\n callback(new Errors.EINVAL('mode not a valid an integer value', value));\r\n return false;\r\n }\r\n }\r\n\r\n if (typeof value === 'string') {\r\n if (!octalReg.test(value)) {\r\n callback(new Errors.EINVAL('mode not a valid octal string', value));\r\n return false;\r\n }\r\n var parsed = parseInt(value, 8);\r\n return parsed & FULL_READ_WRITE_EXEC_PERMISSIONS;\r\n }\r\n\r\n // TODO(BridgeAR): Only return `def` in case `value === null`\r\n if (def !== undefined) {\r\n return def;\r\n }\r\n\r\n callback(new Errors.EINVAL('mode not valid', value));\r\n return false;\r\n}\r\n\r\nfunction chmod_file(context, path, mode, callback) {\r\n path = normalize(path);\r\n\r\n function update_mode(error, node) {\r\n if (error) {\r\n callback(error);\r\n } else {\r\n Node.setMode(mode, node);\r\n update_node_times(context, path, node, { mtime: Date.now() }, callback);\r\n }\r\n }\r\n\r\n if (typeof mode !== 'number') {\r\n callback(new Errors.EINVAL('mode must be number', path));\r\n }\r\n else {\r\n find_node(context, path, update_mode);\r\n }\r\n}\r\n\r\nfunction fchmod_file(context, ofd, mode, callback) {\r\n function update_mode(error, node) {\r\n if (error) {\r\n callback(error);\r\n } else {\r\n node.mode = mode;\r\n update_node_times(context, ofd.path, node, { mtime: Date.now() }, callback);\r\n }\r\n }\r\n\r\n if (typeof mode !== 'number') {\r\n callback(new Errors.EINVAL('mode must be a number'));\r\n }\r\n else {\r\n ofd.getNode(context, update_mode);\r\n }\r\n}\r\n\r\nfunction chown_file(context, path, uid, gid, callback) {\r\n path = normalize(path);\r\n\r\n function update_owner(error, node) {\r\n if (error) {\r\n callback(error);\r\n } else {\r\n node.uid = uid;\r\n node.gid = gid;\r\n update_node_times(context, path, node, { mtime: Date.now() }, callback);\r\n }\r\n }\r\n\r\n find_node(context, path, update_owner);\r\n}\r\n\r\nfunction fchown_file(context, ofd, uid, gid, callback) {\r\n function update_owner(error, node) {\r\n if (error) {\r\n callback(error);\r\n } else {\r\n node.uid = uid;\r\n node.gid = gid;\r\n update_node_times(context, ofd.path, node, { mtime: Date.now() }, callback);\r\n }\r\n }\r\n\r\n ofd.getNode(context, update_owner);\r\n}\r\n\r\nfunction getxattr(fs, context, path, name, callback) {\r\n if (!pathCheck(path, callback)) return;\r\n getxattr_file(context, path, name, callback);\r\n}\r\n\r\nfunction fgetxattr(fs, context, fd, name, callback) {\r\n var ofd = fs.openFiles[fd];\r\n if (!ofd) {\r\n callback(new Errors.EBADF());\r\n }\r\n else {\r\n fgetxattr_file(context, ofd, name, callback);\r\n }\r\n}\r\n\r\nfunction setxattr(fs, context, path, name, value, flag, callback) {\r\n if(typeof flag === 'function') {\r\n callback = flag;\r\n flag = null;\r\n }\r\n\r\n if (!pathCheck(path, callback)) return;\r\n setxattr_file(context, path, name, value, flag, callback);\r\n}\r\n\r\nfunction fsetxattr(fs, context, fd, name, value, flag, callback) {\r\n if(typeof flag === 'function') {\r\n callback = flag;\r\n flag = null;\r\n }\r\n\r\n var ofd = fs.openFiles[fd];\r\n if (!ofd) {\r\n callback(new Errors.EBADF());\r\n }\r\n else if (!_(ofd.flags).contains(O_WRITE)) {\r\n callback(new Errors.EBADF('descriptor does not permit writing'));\r\n }\r\n else {\r\n fsetxattr_file(context, ofd, name, value, flag, callback);\r\n }\r\n}\r\n\r\nfunction removexattr(fs, context, path, name, callback) {\r\n if (!pathCheck(path, callback)) return;\r\n removexattr_file(context, path, name, callback);\r\n}\r\n\r\nfunction fremovexattr(fs, context, fd, name, callback) {\r\n var ofd = fs.openFiles[fd];\r\n if (!ofd) {\r\n callback(new Errors.EBADF());\r\n }\r\n else if (!_(ofd.flags).contains(O_WRITE)) {\r\n callback(new Errors.EBADF('descriptor does not permit writing'));\r\n }\r\n else {\r\n fremovexattr_file(context, ofd, name, callback);\r\n }\r\n}\r\n\r\nfunction lseek(fs, context, fd, offset, whence, callback) {\r\n function update_descriptor_position(error, stats) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n if(stats.size + offset < 0) {\r\n callback(new Errors.EINVAL('resulting file offset would be negative'));\r\n } else {\r\n ofd.position = stats.size + offset;\r\n callback(null, ofd.position);\r\n }\r\n }\r\n }\r\n\r\n var ofd = fs.openFiles[fd];\r\n if(!ofd) {\r\n callback(new Errors.EBADF());\r\n }\r\n\r\n if('SET' === whence) {\r\n if(offset < 0) {\r\n callback(new Errors.EINVAL('resulting file offset would be negative'));\r\n } else {\r\n ofd.position = offset;\r\n callback(null, ofd.position);\r\n }\r\n } else if('CUR' === whence) {\r\n if(ofd.position + offset < 0) {\r\n callback(new Errors.EINVAL('resulting file offset would be negative'));\r\n } else {\r\n ofd.position += offset;\r\n callback(null, ofd.position);\r\n }\r\n } else if('END' === whence) {\r\n fstat_file(context, ofd, update_descriptor_position);\r\n } else {\r\n callback(new Errors.EINVAL('whence argument is not a proper value'));\r\n }\r\n}\r\n\r\nfunction readdir(fs, context, path, callback) {\r\n if(!pathCheck(path, callback)) return;\r\n read_directory(context, path, callback);\r\n}\r\n\r\nfunction utimes(fs, context, path, atime, mtime, callback) {\r\n if(!pathCheck(path, callback)) return;\r\n\r\n var currentTime = Date.now();\r\n atime = (atime) ? atime : currentTime;\r\n mtime = (mtime) ? mtime : currentTime;\r\n\r\n utimes_file(context, path, atime, mtime, callback);\r\n}\r\n\r\nfunction futimes(fs, context, fd, atime, mtime, callback) {\r\n var currentTime = Date.now();\r\n atime = (atime) ? atime : currentTime;\r\n mtime = (mtime) ? mtime : currentTime;\r\n\r\n var ofd = fs.openFiles[fd];\r\n if(!ofd) {\r\n callback(new Errors.EBADF());\r\n } else if(!_(ofd.flags).contains(O_WRITE)) {\r\n callback(new Errors.EBADF('descriptor does not permit writing'));\r\n } else {\r\n futimes_file(context, ofd, atime, mtime, callback);\r\n }\r\n}\r\n\r\nfunction chmod(fs, context, path, mode, callback) {\r\n if(!pathCheck(path, callback)) return;\r\n mode = validateAndMaskMode(mode, 'mode');\r\n if(!mode) return;\r\n\r\n chmod_file(context, path, mode, callback);\r\n}\r\n\r\nfunction fchmod(fs, context, fd, mode, callback) {\r\n mode = validateAndMaskMode(mode, 'mode');\r\n if(!mode) return;\r\n\r\n var ofd = fs.openFiles[fd];\r\n if(!ofd) {\r\n callback(new Errors.EBADF());\r\n } else if(!_(ofd.flags).contains(O_WRITE)) {\r\n callback(new Errors.EBADF('descriptor does not permit writing'));\r\n } else {\r\n fchmod_file(context, ofd, mode, callback);\r\n }\r\n}\r\n\r\nfunction chown(fs, context, path, uid, gid, callback) {\r\n if(!pathCheck(path, callback)) return;\r\n if(!isUint32(uid)) {\r\n return callback(new Errors.EINVAL('uid must be a valid integer', uid));\r\n }\r\n if(!isUint32(gid)) {\r\n return callback(new Errors.EINVAL('gid must be a valid integer', gid));\r\n }\r\n\r\n chown_file(context, path, uid, gid, callback);\r\n}\r\n\r\nfunction fchown(fs, context, fd, uid, gid, callback) {\r\n if(!isUint32(uid)) {\r\n return callback(new Errors.EINVAL('uid must be a valid integer', uid));\r\n }\r\n if(!isUint32(gid)) {\r\n return callback(new Errors.EINVAL('gid must be a valid integer', gid));\r\n }\r\n\r\n var ofd = fs.openFiles[fd];\r\n if(!ofd) {\r\n callback(new Errors.EBADF());\r\n } else if(!_(ofd.flags).contains(O_WRITE)) {\r\n callback(new Errors.EBADF('descriptor does not permit writing'));\r\n } else {\r\n fchown_file(context, ofd, uid, gid, callback);\r\n }\r\n}\r\n\r\nfunction rename(fs, context, oldpath, newpath, callback) {\r\n if(!pathCheck(oldpath, callback)) return;\r\n if(!pathCheck(newpath, callback)) return;\r\n\r\n oldpath = normalize(oldpath);\r\n newpath = normalize(newpath);\r\n\r\n var oldParentPath = Path.dirname(oldpath);\r\n var newParentPath = Path.dirname(oldpath);\r\n var oldName = Path.basename(oldpath);\r\n var newName = Path.basename(newpath);\r\n var oldParentDirectory, oldParentData;\r\n var newParentDirectory, newParentData;\r\n var ctime = Date.now();\r\n var fileNode;\r\n\r\n function update_times(error, result) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n fileNode = result;\r\n update_node_times(context, newpath, fileNode, { ctime: ctime }, callback);\r\n }\r\n }\r\n\r\n function read_new_directory(error) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n context.getObject(newParentData[newName].id, update_times);\r\n }\r\n }\r\n\r\n function update_old_parent_directory_data(error) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n if(oldParentDirectory.id === newParentDirectory.id) {\r\n oldParentData = newParentData;\r\n }\r\n delete oldParentData[oldName];\r\n context.putObject(oldParentDirectory.data, oldParentData, read_new_directory);\r\n }\r\n }\r\n\r\n function update_new_parent_directory_data(error) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n newParentData[newName] = oldParentData[oldName];\r\n context.putObject(newParentDirectory.data, newParentData, update_old_parent_directory_data);\r\n }\r\n }\r\n\r\n function check_if_new_directory_exists(error, result) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n newParentData = result;\r\n if(_(newParentData).has(newName)) {\r\n remove_directory(context, newpath, update_new_parent_directory_data);\r\n } else {\r\n update_new_parent_directory_data();\r\n }\r\n }\r\n }\r\n\r\n function read_new_parent_directory_data(error, result) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n newParentDirectory = result;\r\n context.getObject(newParentDirectory.data, check_if_new_directory_exists);\r\n }\r\n }\r\n\r\n function get_new_parent_directory(error, result) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n oldParentData = result;\r\n find_node(context, newParentPath, read_new_parent_directory_data);\r\n }\r\n }\r\n\r\n function read_parent_directory_data(error, result) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n oldParentDirectory = result;\r\n context.getObject(result.data, get_new_parent_directory);\r\n }\r\n }\r\n\r\n function unlink_old_file(error) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n unlink_node(context, oldpath, callback);\r\n }\r\n }\r\n\r\n function check_node_type(error, node) {\r\n if(error) {\r\n callback(error);\r\n } else if(node.type === NODE_TYPE_DIRECTORY) {\r\n find_node(context, oldParentPath, read_parent_directory_data);\r\n } else {\r\n link_node(context, oldpath, newpath, unlink_old_file);\r\n }\r\n }\r\n\r\n find_node(context, oldpath, check_node_type);\r\n}\r\n\r\nfunction symlink(fs, context, srcpath, dstpath, type, callback) {\r\n // NOTE: we support passing the `type` arg, but ignore it.\r\n callback = arguments[arguments.length - 1];\r\n\r\n // Special Case: allow srcpath to be relative, which we normally don't permit.\r\n // If the srcpath is relative, we assume it's relative to the dirpath of \r\n // dstpath.\r\n if(!pathCheck(srcpath, true, callback)) return;\r\n if(!pathCheck(dstpath, callback)) return;\r\n\r\n make_symbolic_link(context, srcpath, dstpath, callback);\r\n}\r\n\r\nfunction readlink(fs, context, path, callback) {\r\n if(!pathCheck(path, callback)) return;\r\n read_link(context, path, callback);\r\n}\r\n\r\nfunction lstat(fs, context, path, callback) {\r\n if(!pathCheck(path, callback)) return;\r\n\r\n function check_result(error, result) {\r\n if(error) {\r\n callback(error);\r\n } else {\r\n var stats = new Stats(path, result, fs.name);\r\n callback(null, stats);\r\n }\r\n }\r\n\r\n lstat_file(context, path, check_result);\r\n}\r\n\r\nfunction truncate(fs, context, path, length, callback) {\r\n // NOTE: length is optional\r\n callback = arguments[arguments.length - 1];\r\n length = length || 0;\r\n\r\n if(!pathCheck(path, callback)) return;\r\n truncate_file(context, path, length, callback);\r\n}\r\n\r\nfunction ftruncate(fs, context, fd, length, callback) {\r\n // NOTE: length is optional\r\n callback = arguments[arguments.length - 1];\r\n length = length || 0;\r\n\r\n var ofd = fs.openFiles[fd];\r\n if(!ofd) {\r\n callback(new Errors.EBADF());\r\n } else if(!_(ofd.flags).contains(O_WRITE)) {\r\n callback(new Errors.EBADF('descriptor does not permit writing'));\r\n } else {\r\n ftruncate_file(context, ofd, length, callback);\r\n }\r\n}\r\n\r\nmodule.exports = {\r\n ensureRootDirectory: ensure_root_directory,\r\n open: open,\r\n chmod: chmod,\r\n fchmod: fchmod,\r\n chown: chown,\r\n fchown: fchown,\r\n close: close,\r\n mknod: mknod,\r\n mkdir: mkdir,\r\n rmdir: rmdir,\r\n unlink: unlink,\r\n stat: stat,\r\n fstat: fstat,\r\n link: link,\r\n read: read,\r\n readFile: readFile,\r\n write: write,\r\n writeFile: writeFile,\r\n appendFile: appendFile,\r\n exists: exists,\r\n getxattr: getxattr,\r\n fgetxattr: fgetxattr,\r\n setxattr: setxattr,\r\n fsetxattr: fsetxattr,\r\n removexattr: removexattr,\r\n fremovexattr: fremovexattr,\r\n lseek: lseek,\r\n readdir: readdir,\r\n utimes: utimes,\r\n futimes: futimes,\r\n rename: rename,\r\n symlink: symlink,\r\n readlink: readlink,\r\n lstat: lstat,\r\n truncate: truncate,\r\n ftruncate: ftruncate\r\n};\r\n","var _ = require('../../lib/nodash.js');\r\nvar { promisify } = require('es6-promisify');\r\n\r\nvar isNullPath = require('../path.js').isNull;\r\nvar nop = require('../shared.js').nop;\r\n\r\nvar Constants = require('../constants.js');\r\nvar FILE_SYSTEM_NAME = Constants.FILE_SYSTEM_NAME;\r\nvar FS_FORMAT = Constants.FS_FORMAT;\r\nvar FS_READY = Constants.FS_READY;\r\nvar FS_PENDING = Constants.FS_PENDING;\r\nvar FS_ERROR = Constants.FS_ERROR;\r\nvar FS_NODUPEIDCHECK = Constants.FS_NODUPEIDCHECK;\r\n\r\nvar providers = require('../providers/index.js');\r\n\r\nvar Shell = require('../shell/shell.js');\r\nvar Intercom = require('../../lib/intercom.js');\r\nvar FSWatcher = require('../fs-watcher.js');\r\nvar Errors = require('../errors.js');\r\nvar defaultGuidFn = require('../shared.js').guid;\r\n\r\nvar STDIN = Constants.STDIN;\r\nvar STDOUT = Constants.STDOUT;\r\nvar STDERR = Constants.STDERR;\r\nvar FIRST_DESCRIPTOR = Constants.FIRST_DESCRIPTOR;\r\n\r\n// The core fs operations live on impl\r\nvar impl = require('./implementation.js');\r\n\r\n// node.js supports a calling pattern that leaves off a callback.\r\nfunction maybeCallback(callback) {\r\n if(typeof callback === 'function') {\r\n return callback;\r\n }\r\n return function(err) {\r\n if(err) {\r\n throw err;\r\n }\r\n };\r\n}\r\n\r\n// Default callback that logs an error if passed in\r\nfunction defaultCallback(err) {\r\n if(err) {\r\n /* eslint no-console: 0 */\r\n console.error('Filer error: ', err);\r\n }\r\n}\r\n\r\n/**\r\n * FileSystem\r\n *\r\n * A FileSystem takes an `options` object, which can specify a number of,\r\n * options. All options are optional, and include:\r\n *\r\n * name: the name of the file system, defaults to \"local\"\r\n *\r\n * flags: one or more flags to use when creating/opening the file system.\r\n * For example: \"FORMAT\" will cause the file system to be formatted.\r\n * No explicit flags are set by default.\r\n *\r\n * provider: an explicit storage provider to use for the file\r\n * system's database context provider. A number of context\r\n * providers are included (see /src/providers), and users\r\n * can write one of their own and pass it in to be used.\r\n * By default an IndexedDB provider is used.\r\n *\r\n * guid: a function for generating unique IDs for nodes in the filesystem.\r\n * Use this to override the built-in UUID generation. (Used mainly for tests).\r\n *\r\n * callback: a callback function to be executed when the file system becomes\r\n * ready for use. Depending on the context provider used, this might\r\n * be right away, or could take some time. The callback should expect\r\n * an `error` argument, which will be null if everything worked. Also\r\n * users should check the file system's `readyState` and `error`\r\n * properties to make sure it is usable.\r\n */\r\nfunction FileSystem(options, callback) {\r\n options = options || {};\r\n callback = callback || defaultCallback;\r\n\r\n var flags = options.flags;\r\n var guid = options.guid ? options.guid : defaultGuidFn;\r\n var provider = options.provider || new providers.Default(options.name || FILE_SYSTEM_NAME);\r\n // If we're given a provider, match its name unless we get an explicit name\r\n var name = options.name || provider.name;\r\n var forceFormatting = _(flags).contains(FS_FORMAT);\r\n\r\n var fs = this;\r\n fs.readyState = FS_PENDING;\r\n fs.name = name;\r\n fs.error = null;\r\n\r\n fs.stdin = STDIN;\r\n fs.stdout = STDOUT;\r\n fs.stderr = STDERR;\r\n\r\n // Expose Node's fs.constants to users\r\n fs.constants = Constants.fsConstants;\r\n\r\n // Expose Shell constructor\r\n this.Shell = Shell.bind(undefined, this);\r\n\r\n // Safely expose the list of open files and file\r\n // descriptor management functions\r\n var openFiles = {};\r\n var nextDescriptor = FIRST_DESCRIPTOR;\r\n Object.defineProperty(this, 'openFiles', {\r\n get: function() { return openFiles; }\r\n });\r\n this.allocDescriptor = function(openFileDescription) {\r\n var fd = nextDescriptor ++;\r\n openFiles[fd] = openFileDescription;\r\n return fd;\r\n };\r\n this.releaseDescriptor = function(fd) {\r\n delete openFiles[fd];\r\n };\r\n\r\n // Safely expose the operation queue\r\n var queue = [];\r\n this.queueOrRun = function(operation) {\r\n var error;\r\n\r\n if(FS_READY == fs.readyState) {\r\n operation.call(fs);\r\n } else if(FS_ERROR == fs.readyState) {\r\n error = new Errors.EFILESYSTEMERROR('unknown error');\r\n } else {\r\n queue.push(operation);\r\n }\r\n\r\n return error;\r\n };\r\n function runQueued() {\r\n queue.forEach(function(operation) {\r\n operation.call(this);\r\n }.bind(fs));\r\n queue = null;\r\n }\r\n\r\n // We support the optional `options` arg from node, but ignore it\r\n this.watch = function(filename, options, listener) {\r\n if(isNullPath(filename)) {\r\n throw new Error('Path must be a string without null bytes.');\r\n }\r\n if(typeof options === 'function') {\r\n listener = options;\r\n options = {};\r\n }\r\n options = options || {};\r\n listener = listener || nop;\r\n\r\n var watcher = new FSWatcher();\r\n watcher.start(filename, false, options.recursive);\r\n watcher.on('change', listener);\r\n\r\n return watcher;\r\n };\r\n\r\n // Deal with various approaches to node ID creation\r\n function wrappedGuidFn(context) {\r\n return function(callback) {\r\n // Skip the duplicate ID check if asked to\r\n if(_(flags).contains(FS_NODUPEIDCHECK)) {\r\n callback(null, guid());\r\n return;\r\n }\r\n\r\n // Otherwise (default) make sure this id is unused first\r\n function guidWithCheck(callback) {\r\n var id = guid();\r\n context.getObject(id, function(err, value) {\r\n if(err) {\r\n callback(err);\r\n return;\r\n }\r\n\r\n // If this id is unused, use it, otherwise find another\r\n if(!value) {\r\n callback(null, id);\r\n } else {\r\n guidWithCheck(callback);\r\n }\r\n });\r\n }\r\n guidWithCheck(callback);\r\n };\r\n }\r\n\r\n // Let other instances (in this or other windows) know about\r\n // any changes to this fs instance.\r\n function broadcastChanges(changes) {\r\n if(!changes.length) {\r\n return;\r\n }\r\n var intercom = Intercom.getInstance();\r\n changes.forEach(function(change) {\r\n intercom.emit(change.event, change.path);\r\n });\r\n }\r\n\r\n // Open file system storage provider\r\n provider.open(function(err) {\r\n function complete(error) {\r\n function wrappedContext(methodName) {\r\n var context = provider[methodName]();\r\n context.flags = flags;\r\n context.changes = [];\r\n context.guid = wrappedGuidFn(context);\r\n\r\n // When the context is finished, let the fs deal with any change events\r\n context.close = function() {\r\n var changes = context.changes;\r\n broadcastChanges(changes);\r\n changes.length = 0;\r\n };\r\n\r\n return context;\r\n }\r\n\r\n // Wrap the provider so we can extend the context with fs flags and\r\n // an array of changes (e.g., watch event 'change' and 'rename' events\r\n // for paths updated during the lifetime of the context). From this\r\n // point forward we won't call open again, so it's safe to drop it.\r\n fs.provider = {\r\n openReadWriteContext: function() {\r\n return wrappedContext('getReadWriteContext');\r\n },\r\n openReadOnlyContext: function() {\r\n return wrappedContext('getReadOnlyContext');\r\n }\r\n };\r\n\r\n if(error) {\r\n fs.readyState = FS_ERROR;\r\n } else {\r\n fs.readyState = FS_READY;\r\n }\r\n runQueued();\r\n callback(error, fs);\r\n }\r\n\r\n if(err) {\r\n return complete(err);\r\n }\r\n\r\n var context = provider.getReadWriteContext();\r\n context.guid = wrappedGuidFn(context);\r\n\r\n // Mount the filesystem, formatting if necessary\r\n if(forceFormatting) {\r\n // Wipe the storage provider, then write root block\r\n context.clear(function(err) {\r\n if(err) {\r\n return complete(err);\r\n }\r\n impl.ensureRootDirectory(context, complete);\r\n });\r\n } else {\r\n // Use existing (or create new) root and mount\r\n impl.ensureRootDirectory(context, complete);\r\n }\r\n });\r\n FileSystem.prototype.promises = {};\r\n /**\r\n * Public API for FileSystem\r\n */\r\n [\r\n 'open',\r\n 'chmod',\r\n 'fchmod',\r\n 'chown',\r\n 'fchown',\r\n 'close',\r\n 'mknod',\r\n 'mkdir',\r\n 'rmdir',\r\n 'stat',\r\n 'fstat',\r\n 'link',\r\n 'unlink',\r\n 'read',\r\n 'readFile',\r\n 'write',\r\n 'writeFile',\r\n 'appendFile',\r\n 'exists',\r\n 'lseek',\r\n 'readdir',\r\n 'rename',\r\n 'readlink',\r\n 'symlink',\r\n 'lstat',\r\n 'truncate',\r\n 'ftruncate',\r\n 'utimes',\r\n 'futimes',\r\n 'setxattr',\r\n 'getxattr',\r\n 'fsetxattr',\r\n 'fgetxattr',\r\n 'removexattr',\r\n 'fremovexattr'\r\n ].forEach(function(methodName) {\r\n FileSystem.prototype[methodName] = function() {\r\n var fs = this;\r\n var args = Array.prototype.slice.call(arguments, 0);\r\n var lastArgIndex = args.length - 1;\r\n\r\n // We may or may not get a callback, and since node.js supports\r\n // fire-and-forget style fs operations, we have to dance a bit here.\r\n var missingCallback = typeof args[lastArgIndex] !== 'function';\r\n var callback = maybeCallback(args[lastArgIndex]);\r\n\r\n var error = fs.queueOrRun(function() {\r\n var context = fs.provider.openReadWriteContext();\r\n\r\n // Fail early if the filesystem is in an error state (e.g.,\r\n // provider failed to open.\r\n if(FS_ERROR === fs.readyState) {\r\n var err = new Errors.EFILESYSTEMERROR('filesystem unavailable, operation canceled');\r\n return callback.call(fs, err);\r\n }\r\n\r\n // Wrap the callback so we can explicitly close the context\r\n function complete() {\r\n context.close();\r\n callback.apply(fs, arguments);\r\n }\r\n\r\n // Either add or replace the callback with our wrapper complete()\r\n if(missingCallback) {\r\n args.push(complete);\r\n } else {\r\n args[lastArgIndex] = complete;\r\n }\r\n\r\n // Forward this call to the impl's version, using the following\r\n // call signature, with complete() as the callback/last-arg now:\r\n // fn(fs, context, arg0, arg1, ... , complete);\r\n var fnArgs = [fs, context].concat(args);\r\n impl[methodName].apply(null, fnArgs);\r\n });\r\n if(error) {\r\n callback(error);\r\n }\r\n };\r\n \r\n FileSystem.prototype.promises[methodName] = promisify(FileSystem.prototype[methodName].bind(fs));\r\n });\r\n\r\n}\r\n\r\n// Expose storage providers on FileSystem constructor\r\nFileSystem.providers = providers;\r\n\r\nmodule.exports = FileSystem;\r\n","module.exports = {\r\n FileSystem: require('./filesystem/interface.js'),\r\n Buffer: require('./buffer.js'),\r\n Path: require('./path.js'),\r\n Errors: require('./errors.js'),\r\n Shell: require('./shell/shell.js')\r\n};\r\n"]}