First commit
This commit is contained in:
76
application/elements/fileChooser/fileChooser.files.js
Normal file
76
application/elements/fileChooser/fileChooser.files.js
Normal file
@@ -0,0 +1,76 @@
|
||||
|
||||
#ifdef SERVER
|
||||
|
||||
import fs from "fs";
|
||||
|
||||
import path from "path";
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
import file from "./fileChooser.file.js";
|
||||
|
||||
export default class fileChooserFiles{
|
||||
|
||||
async open() {
|
||||
|
||||
var relativePath = "./";
|
||||
|
||||
var systemPath = await this.getSystemPath( relativePath )
|
||||
|
||||
var files = await this.getDirectory( systemPath );
|
||||
|
||||
}
|
||||
|
||||
node async getSystemPath( relativePath ) {
|
||||
|
||||
var absolutePath = path.resolve( relativePath );
|
||||
|
||||
console.log("getSystemPath", absolutePath);
|
||||
|
||||
return absolutePath;
|
||||
|
||||
}
|
||||
|
||||
node async getDirectory( absolutePath ) {
|
||||
|
||||
var files = fs.readdirSync( absolutePath );
|
||||
|
||||
|
||||
for (var i = 0; i < files.length; i++) {
|
||||
|
||||
var filename = files[i];
|
||||
|
||||
var fileStat = fs.lstatSync( absolutePath + "/" + filename );
|
||||
|
||||
|
||||
var currentFile = new file();
|
||||
|
||||
|
||||
currentFile.filename = filename;
|
||||
|
||||
currentFile.path = absolutePath;
|
||||
|
||||
if( fileStat.isDirectory() ) {
|
||||
|
||||
currentFile.fileType = "directory";
|
||||
|
||||
} else {
|
||||
|
||||
currentFile.fileType = "file";
|
||||
|
||||
}
|
||||
|
||||
console.log("add file", currentFile);
|
||||
|
||||
this.add( currentFile );
|
||||
|
||||
}
|
||||
|
||||
console.log("readdirSync", files);
|
||||
|
||||
return files;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user