Skip to content

Commit e593459

Browse files
committed
phoenix fslib check
1 parent 860d717 commit e593459

13 files changed

Lines changed: 1142 additions & 38 deletions

dist/virtualfs.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/virtualfs.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/filerlib_copy.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*/
1818

1919
// jshint ignore: start
20-
/*global fs*/
20+
/*global fs, globalObject*/
2121
/*eslint no-console: 0*/
2222
/*eslint strict: ["error", "global"]*/
2323

@@ -80,8 +80,8 @@ async function _copyFileContents(src, dst) {
8080
async function _copyFile(srcFile, dst) {
8181
let dstStat = await _stat(dst);
8282
if(!dstStat){
83-
let parentDir= window.path.dirname(dst);
84-
let dstFileName= window.path.basename(dst);
83+
let parentDir= globalObject.path.dirname(dst);
84+
let dstFileName= globalObject.path.basename(dst);
8585
dstStat = await _stat(parentDir);
8686
if(dstStat && dstStat.isDirectory()){
8787
let dstFilePath =`${parentDir}/${dstFileName}`;
@@ -92,7 +92,7 @@ async function _copyFile(srcFile, dst) {
9292
}
9393
}
9494

95-
let srcFileName= window.path.basename(srcFile);
95+
let srcFileName= globalObject.path.basename(srcFile);
9696
if(dstStat && dstStat.isDirectory()){
9797
let dstFilePath =`${dst}/${srcFileName}`;
9898
await _copyFileContents(srcFile, dstFilePath);
@@ -149,7 +149,7 @@ async function copy(src, dst, callback) {
149149
}
150150

151151
function filerCopy(src, dst, cb) {
152-
copy(window.path.normalize(src), window.path.normalize(dst), cb);
152+
copy(globalObject.path.normalize(src), globalObject.path.normalize(dst), cb);
153153
}
154154

155155
module.exports ={

src/fslib.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*/
1818

1919
// jshint ignore: start
20-
/*global process*/
20+
/*global process, globalObject*/
2121
/*eslint no-console: 0*/
2222
/*eslint strict: ["error", "global"]*/
2323

@@ -247,12 +247,13 @@ const fileSystemLib = {
247247
};
248248

249249
fileSystemLib.copyFile = fileSystemLib.copy;
250+
fileSystemLib.name = 'phoenixFS';
250251

251252
function initFsLib(FilerLib) {
252253
filerLib = FilerLib;
253254
filerShell = new filerLib.fs.Shell();
254-
window.path = FilerLib.path;
255-
window.fs = fileSystemLib;
255+
globalObject.path = FilerLib.path;
256+
globalObject.fs = fileSystemLib;
256257

257258
_ensure_mount_directory();
258259
}

src/fslib_mounts.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*/
1818

1919
// jshint ignore: start
20-
/*global BroadcastChannel*/
20+
/*global BroadcastChannel, globalObject*/
2121
/*eslint no-console: 0*/
2222
/*eslint strict: ["error", "global"]*/
2323

@@ -41,7 +41,7 @@ function isMountSubPath(path) {
4141
}
4242
let mntSubPathStart = '/mnt/';
4343
if (path) {
44-
path = window.path.normalize(path);
44+
path = globalObject.path.normalize(path);
4545
if (path.startsWith(mntSubPathStart) && path.length > mntSubPathStart.length) {
4646
return true;
4747
}
@@ -58,7 +58,7 @@ function isMountPath(path) {
5858
return false;
5959
}
6060
if (path) {
61-
path = window.path.normalize(path);
61+
path = globalObject.path.normalize(path);
6262
if (path === Constants.MOUNT_POINT_ROOT) {
6363
return true;
6464
}
@@ -73,7 +73,7 @@ function _setupBroadcastChannel() {
7373
}
7474
if(typeof BroadcastChannel === 'undefined'){
7575
/* eslint no-console: 0 */
76-
console.warn('window.BroadcastChannel not supported. Mount point changes wont reflect across tabs.');
76+
console.warn('BroadcastChannel not supported. Mount point changes wont reflect across tabs.');
7777
return;
7878
}
7979
_channel = new BroadcastChannel(MOUNT_POINT_CHANGED_NOTIFICATION);
@@ -186,7 +186,7 @@ function mountNativeFolder(optionalDirHandle, callback) {
186186
let mountedPath = null;
187187
let error = null;
188188
MountPointsStore.refreshMountPoints()
189-
.then(() => optionalDirHandle || window.showDirectoryPicker())
189+
.then(() => optionalDirHandle || globalObject.showDirectoryPicker())
190190
.then((directoryHandle) => _mountHandle(directoryHandle))
191191
.then( mountPath => mountedPath = mountPath)
192192
.then(() => _broadcastMountPointChanged())

src/fslib_native.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*/
1818

1919
// jshint ignore: start
20-
/*global TextDecoder, buffer*/
20+
/*global TextDecoder, buffer, globalObject*/
2121
/*eslint no-console: 0*/
2222
/*eslint strict: ["error", "global"]*/
2323

@@ -60,9 +60,9 @@ function mkdir(path, mode, callback) {
6060
callback = mode;
6161
}
6262

63-
path = window.path.normalize(path);
64-
let dirname= window.path.dirname(path);
65-
let subdirName= window.path.basename(path);
63+
path = globalObject.path.normalize(path);
64+
let dirname= globalObject.path.dirname(path);
65+
let subdirName= globalObject.path.basename(path);
6666
Mounts.getHandleFromPath(dirname, (err, handle) => {
6767
if(err){
6868
callback(err);
@@ -76,7 +76,7 @@ function mkdir(path, mode, callback) {
7676

7777

7878
function readdir(path, options, callback) {
79-
path = window.path.normalize(path);
79+
path = globalObject.path.normalize(path);
8080
if (typeof options !== 'function') {
8181
throw new Errors.ENOSYS('Filer readdir options are not yet supported');
8282
}
@@ -138,7 +138,7 @@ function _validateFileOptions(options, enc, fileMode){
138138
}
139139

140140
function readFile(path, options, callback) {
141-
path = window.path.normalize(path);
141+
path = globalObject.path.normalize(path);
142142

143143
callback = arguments[arguments.length - 1];
144144
options = _validateFileOptions(options, null, 'r');
@@ -156,7 +156,7 @@ function readFile(path, options, callback) {
156156

157157

158158
function stat(path, callback) {
159-
path = window.path.normalize(path);
159+
path = globalObject.path.normalize(path);
160160
Mounts.getHandleFromPath(path, (err, handle) => {
161161
if(err){
162162
callback(err);
@@ -198,9 +198,9 @@ function writeFile (path, data, options, callback) {
198198
}
199199
}
200200

201-
path = window.path.normalize(path);
202-
let dirname= window.path.dirname(path);
203-
let fileName= window.path.basename(path);
201+
path = globalObject.path.normalize(path);
202+
let dirname= globalObject.path.dirname(path);
203+
let fileName= globalObject.path.basename(path);
204204
Mounts.getHandleFromPath(dirname, (err, handle) => {
205205
if(err){
206206
callback(err);
@@ -222,9 +222,9 @@ async function _deleteEntry(dirHandle, entryNameToDelete, callback, recursive=tr
222222
}
223223

224224
async function unlink(path, callback) {
225-
path = window.path.normalize(path);
226-
let dirPath= window.path.dirname(path);
227-
let baseName= window.path.basename(path);
225+
path = globalObject.path.normalize(path);
226+
let dirPath= globalObject.path.dirname(path);
227+
let baseName= globalObject.path.basename(path);
228228
Mounts.getHandleFromPath(dirPath, async (err, dirHandle) => {
229229
if(err){
230230
callback(err);
@@ -236,9 +236,9 @@ async function unlink(path, callback) {
236236

237237
async function _getDestinationHandleForCopy(dst, srcBaseName, handleKindToCreate) {
238238
return new Promise(async (resolve, reject) => {
239-
dst = window.path.normalize(dst);
240-
let dirPath= window.path.dirname(dst);
241-
let dstBaseName= window.path.basename(dst);
239+
dst = globalObject.path.normalize(dst);
240+
let dirPath= globalObject.path.dirname(dst);
241+
let dstBaseName= globalObject.path.basename(dst);
242242
let dstHandle = await Mounts.getHandleFromPathIfPresent(dst);
243243
let dstParentHandle = await Mounts.getHandleFromPathIfPresent(dirPath);
244244
if (dstHandle && dstHandle.kind === Constants.KIND_FILE) {
@@ -322,8 +322,8 @@ async function _copyFolderWithHandle(srcFolderHandle, dst, srcFileName, callback
322322
}
323323

324324
async function copy(src, dst, callback, recursive = true) {
325-
let srcFile = window.path.normalize(src);
326-
let srcFileName= window.path.basename(srcFile);
325+
let srcFile = globalObject.path.normalize(src);
326+
let srcFileName= globalObject.path.basename(srcFile);
327327
Mounts.getHandleFromPath(srcFile, async (err, srcHandle) => {
328328
if(err){
329329
callback(err);

src/fslib_watch.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
let _channel = null;
2626
let _watchListeners = [];
27-
const globMatch = require('thirdparty/globmatch');
27+
const globMatch = require('./thirdparty/globmatch');
2828

2929
const WATCH_EVENT_NOTIFICATION = 'PHOENIX_WATCH_EVENT_NOTIFICATION';
3030
const WATCH_EVENT_CREATED = 'created';

0 commit comments

Comments
 (0)