mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-17 04:41:36 +08:00
Updated the FileSystem APIs as per review comments.
This commit is contained in:
45
FileSystem/file_system.d.ts
vendored
45
FileSystem/file_system.d.ts
vendored
@ -3,22 +3,27 @@
|
|||||||
* Gets the Date object specifying the last time this entity was modified.
|
* Gets the Date object specifying the last time this entity was modified.
|
||||||
*/
|
*/
|
||||||
public lastModified: Date;
|
public lastModified: Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the name of the entity.
|
* Gets the name of the entity.
|
||||||
*/
|
*/
|
||||||
public name: string;
|
public name: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the fully-qualified path (including the extension for a File) of the entity.
|
* Gets the fully-qualified path (including the extension for a File) of the entity.
|
||||||
*/
|
*/
|
||||||
public path: string;
|
public path: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the Folder object representing the parent of this entity. Will be null for a root folder like Documents or Temporary.
|
* Gets the Folder object representing the parent of this entity. Will be null for a root folder like Documents or Temporary.
|
||||||
*/
|
*/
|
||||||
public getParent(onError?: (error: any) => any): Folder;
|
public getParent(onError?: (error: any) => any): Folder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes the current Entity from the file system.
|
* Removes (deletes) the current Entity from the file system.
|
||||||
*/
|
*/
|
||||||
public delete(onSuccess?: () => any, onError?: (error: any) => any);
|
public remove(onSuccess?: () => any, onError?: (error: any) => any);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renames the current entity using the specified name.
|
* Renames the current entity using the specified name.
|
||||||
*/
|
*/
|
||||||
@ -26,26 +31,31 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
export declare class File extends FileSystemEntity {
|
export declare class File extends FileSystemEntity {
|
||||||
|
/**
|
||||||
|
* Checks whether a File with the specified path already exists.
|
||||||
|
*/
|
||||||
|
public static exists(path: string): boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the extension of the file.
|
* Gets the extension of the file.
|
||||||
*/
|
*/
|
||||||
public extension: string;
|
public extension: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a value indicating whether the file is currently locked, meaning a background operation associated with this file is running.
|
* Gets a value indicating whether the file is currently locked, meaning a background operation associated with this file is running.
|
||||||
*/
|
*/
|
||||||
public isLocked: boolean;
|
public isLocked: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets or creates a File entity at the specified path.
|
* Gets or creates a File entity at the specified path.
|
||||||
*/
|
*/
|
||||||
public static fromPath(path: string, onError?: (error: any) => any): File;
|
public static fromPath(path: string, onError?: (error: any) => any): File;
|
||||||
/**
|
|
||||||
* Checks whether a File with the specified path already exists.
|
|
||||||
*/
|
|
||||||
public static exists(path: string): boolean;
|
|
||||||
/**
|
/**
|
||||||
* Creates a FileReader object over this file and locks the file until the reader is released.
|
* Creates a FileReader object over this file and locks the file until the reader is released.
|
||||||
*/
|
*/
|
||||||
public openRead(): FileReader;
|
public openRead(): FileReader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a FileWriter object over this file and locks the file until the writer is released.
|
* Creates a FileWriter object over this file and locks the file until the writer is released.
|
||||||
*/
|
*/
|
||||||
@ -69,19 +79,15 @@ export declare class Folder extends FileSystemEntity {
|
|||||||
public static exists(path: string): boolean;
|
public static exists(path: string): boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether this Folder contains a file with the specified name.
|
Checks whether this Folder contains an Entity with the specified name.
|
||||||
|
The path of the folder is added to the name to resolve the complete path to check for.
|
||||||
*/
|
*/
|
||||||
public containsFile(name: string): boolean;
|
public contains(name: string): boolean;
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks whether this Folder contains a Folder with the specified name.
|
|
||||||
*/
|
|
||||||
public containsFolder(name: string): boolean;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes all the files and folders (recursively), contained within this Folder.
|
* Deletes all the files and folders (recursively), contained within this Folder.
|
||||||
*/
|
*/
|
||||||
public empty(onSuccess?: () => any, onError?: (error: any) => any);
|
public clear(onSuccess?: () => any, onError?: (error: any) => any);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets or creates a File entity with the specified name within this Folder.
|
* Gets or creates a File entity with the specified name within this Folder.
|
||||||
@ -94,9 +100,16 @@ export declare class Folder extends FileSystemEntity {
|
|||||||
public getFolder(name: string, onError?: (error: any) => any): Folder;
|
public getFolder(name: string, onError?: (error: any) => any): Folder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets all the top-level FileSystem entities residing within this Folder.
|
* Gets all the top-level entities residing within this folder.
|
||||||
*/
|
*/
|
||||||
public enumEntities(onSuccess: (entities: Array<FileSystemEntity>) => any, onError?: (error: any) => any);
|
public getEntities(onSuccess: (entities: Array<FileSystemEntity>) => any, onError?: (error) => any);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Enumerates all the top-level FileSystem entities residing within this folder.
|
||||||
|
The first parameter is a callback that receives the current entity.
|
||||||
|
If the callback returns false this will mean for the iteration to stop.
|
||||||
|
*/
|
||||||
|
public eachEntity(onEntity: (entity: FileSystemEntity) => boolean, onError?: (error: any) => any);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -64,9 +64,9 @@ export class FileSystemEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes the current entity from the file system.
|
* Removes the current entity from the file system.
|
||||||
*/
|
*/
|
||||||
public delete(onSuccess?: () => any, onError?: (error: any) => any) {
|
public remove(onSuccess?: () => any, onError?: (error: any) => any) {
|
||||||
if (this instanceof File) {
|
if (this instanceof File) {
|
||||||
getFileAccess().deleteFile(this.path, onSuccess, onError);
|
getFileAccess().deleteFile(this.path, onSuccess, onError);
|
||||||
} else if (this instanceof Folder) {
|
} else if (this instanceof Folder) {
|
||||||
@ -233,25 +233,21 @@ export class Folder extends FileSystemEntity {
|
|||||||
/**
|
/**
|
||||||
* Checks whether this Folder contains a file with the specified name.
|
* Checks whether this Folder contains a file with the specified name.
|
||||||
*/
|
*/
|
||||||
public containsFile(name: string): boolean {
|
public contains(name: string): boolean {
|
||||||
var fileAccess = getFileAccess();
|
var fileAccess = getFileAccess();
|
||||||
var path = fileAccess.concatPath(this.path, name);
|
var path = fileAccess.concatPath(this.path, name);
|
||||||
return fileAccess.fileExists(path);
|
|
||||||
|
if (fileAccess.fileExists(path)) {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks whether this Folder contains a Folder with the specified name.
|
|
||||||
*/
|
|
||||||
public containsFolder(name: string): boolean {
|
|
||||||
var fileAccess = getFileAccess();
|
|
||||||
var path = fileAccess.concatPath(this.path, name);
|
|
||||||
return fileAccess.folderExists(path);
|
return fileAccess.folderExists(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes all the files and folders (recursively), contained within this Folder.
|
* Removes all the files and folders (recursively), contained within this Folder.
|
||||||
*/
|
*/
|
||||||
public empty(onSuccess?: () => any, onError?: (error: any) => any) {
|
public clear(onSuccess?: () => any, onError?: (error: any) => any) {
|
||||||
getFileAccess().emptyFolder(this.path, onSuccess, onError);
|
getFileAccess().emptyFolder(this.path, onSuccess, onError);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -295,7 +291,7 @@ export class Folder extends FileSystemEntity {
|
|||||||
/**
|
/**
|
||||||
* Gets all the top-level FileSystem entities residing within this Folder.
|
* Gets all the top-level FileSystem entities residing within this Folder.
|
||||||
*/
|
*/
|
||||||
public enumEntities(onSuccess: (files: Array<FileSystemEntity>) => any, onError?: (error: any) => any) {
|
public getEntities(onSuccess: (files: Array<FileSystemEntity>) => any, onError?: (error: any) => any) {
|
||||||
var localSuccess = function (fileInfos: Array<{ path: string; name: string; extension: string }>) {
|
var localSuccess = function (fileInfos: Array<{ path: string; name: string; extension: string }>) {
|
||||||
if (onSuccess) {
|
if (onSuccess) {
|
||||||
var entities = new Array<FileSystemEntity>();
|
var entities = new Array<FileSystemEntity>();
|
||||||
@ -314,7 +310,30 @@ export class Folder extends FileSystemEntity {
|
|||||||
onSuccess(entities);
|
onSuccess(entities);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
getFileAccess().enumFiles(this.path, localSuccess, onError);
|
getFileAccess().getEntities(this.path, localSuccess, onError);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Enumerates all the top-level FileSystem entities residing within this folder.
|
||||||
|
The first parameter is a callback that receives the current entity.
|
||||||
|
If the callback returns false this will mean for the iteration to stop.
|
||||||
|
*/
|
||||||
|
public eachEntity(onEntity: (entity: FileSystemEntity) => boolean, onError?: (error: any) => any) {
|
||||||
|
if (!onEntity) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var localSuccess = function (fileInfo: { path: string; name: string; extension: string }): boolean {
|
||||||
|
var entity;
|
||||||
|
if (fileInfo.extension) {
|
||||||
|
entity = createFile(fileInfo);
|
||||||
|
} else {
|
||||||
|
entity = createFolder(fileInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
return onEntity(entity);
|
||||||
|
}
|
||||||
|
getFileAccess().eachEntity(this.path, localSuccess, onError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,48 +40,38 @@ export class FileSystemAccess {
|
|||||||
return { path: dirInfo.path, name: dirInfo.name };
|
return { path: dirInfo.path, name: dirInfo.name };
|
||||||
}
|
}
|
||||||
|
|
||||||
public enumFiles(path: string, onSuccess: (files: Array<{ path: string; name: string; extension: string }>) => any, onError?: (error: any) => any) {
|
public eachEntity(path: string, onEntity: (file: { path: string; name: string; extension: string }) => boolean, onError?: (error: any) => any) {
|
||||||
try {
|
if (!onEntity) {
|
||||||
var javaFile = new java.io.File(path);
|
return;
|
||||||
if (!javaFile.getCanonicalFile().isDirectory()) {
|
}
|
||||||
if (onError) {
|
|
||||||
onError("There is no folder existing at path " + path);
|
this.enumEntities(path, onEntity, onError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getEntities(path: string, onSuccess: (files: Array<{ path: string; name: string; extension: string }>) => any, onError?: (error: any) => any) {
|
||||||
|
if (!onSuccess) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var filesList: any = javaFile.listFiles();
|
|
||||||
var fileInfos = new Array<{ path: string; name: string; extension: string }>();
|
var fileInfos = new Array<{ path: string; name: string; extension: string }>();
|
||||||
|
var onEntity = function (entity: { path: string; name: string; extension: string }): boolean {
|
||||||
var length = filesList.length,
|
fileInfos.push(entity);
|
||||||
i,
|
return true;
|
||||||
filePath,
|
|
||||||
info;
|
|
||||||
|
|
||||||
for (i = 0; i < length; i++) {
|
|
||||||
javaFile = filesList[i];
|
|
||||||
|
|
||||||
info = {
|
|
||||||
path: javaFile.getAbsolutePath(),
|
|
||||||
name: javaFile.getName()
|
|
||||||
};
|
|
||||||
|
|
||||||
if (javaFile.isFile()) {
|
|
||||||
info.extension = this.getFileExtension(info.path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fileInfos.push(info);
|
var errorOccurred;
|
||||||
}
|
var localError = function (error: any) {
|
||||||
|
|
||||||
if (onSuccess) {
|
|
||||||
onSuccess(fileInfos);
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (exception) {
|
|
||||||
if (onError) {
|
if (onError) {
|
||||||
onError(exception);
|
onError(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
errorOccurred = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.enumEntities(path, onEntity, localError);
|
||||||
|
|
||||||
|
if (!errorOccurred) {
|
||||||
|
onSuccess(fileInfos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -346,13 +336,56 @@ export class FileSystemAccess {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: This method is the same as in the iOS implementation.
|
||||||
|
// Make it in a separate file / module so it can be reused from both implementations.
|
||||||
private getFileExtension(path: string): string {
|
private getFileExtension(path: string): string {
|
||||||
var dotIndex = path.lastIndexOf(".");
|
var dotIndex = path.lastIndexOf(".");
|
||||||
if (dotIndex && dotIndex >= 0 && dotIndex < path.length) {
|
if (dotIndex && dotIndex >= 0 && dotIndex < path.length) {
|
||||||
// return the extension without the "." (like in iOS)
|
return path.substring(dotIndex);
|
||||||
return path.substring(dotIndex + 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return undefined;
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
private enumEntities(path: string, callback: (entity: { path: string; name: string; extension: string }) => boolean, onError?: (error) => any) {
|
||||||
|
try {
|
||||||
|
var javaFile = new java.io.File(path);
|
||||||
|
if (!javaFile.getCanonicalFile().isDirectory()) {
|
||||||
|
if (onError) {
|
||||||
|
onError("There is no folder existing at path " + path);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var filesList = javaFile.listFiles();
|
||||||
|
var length = filesList.length,
|
||||||
|
i,
|
||||||
|
filePath,
|
||||||
|
info,
|
||||||
|
retVal;
|
||||||
|
|
||||||
|
for (i = 0; i < length; i++) {
|
||||||
|
javaFile = filesList[i];
|
||||||
|
|
||||||
|
info = {
|
||||||
|
path: javaFile.getAbsolutePath(),
|
||||||
|
name: javaFile.getName()
|
||||||
|
};
|
||||||
|
|
||||||
|
if (javaFile.isFile()) {
|
||||||
|
info.extension = this.getFileExtension(info.path);
|
||||||
|
}
|
||||||
|
|
||||||
|
retVal = callback(info);
|
||||||
|
if (retVal != undefined && !retVal) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (exception) {
|
||||||
|
if (onError) {
|
||||||
|
onError(exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
5
FileSystem/file_system_access.d.ts
vendored
5
FileSystem/file_system_access.d.ts
vendored
@ -7,7 +7,10 @@ export declare class FileSystemAccess {
|
|||||||
getParent(path: string, onError?: (error: any) => any): { path: string; name: string };
|
getParent(path: string, onError?: (error: any) => any): { path: string; name: string };
|
||||||
getFile(path: string, onError?: (error: any) => any): { path: string; name: string; extension: string };
|
getFile(path: string, onError?: (error: any) => any): { path: string; name: string; extension: string };
|
||||||
getFolder(path: string, onError?: (error: any) => any): { path: string; name: string };
|
getFolder(path: string, onError?: (error: any) => any): { path: string; name: string };
|
||||||
enumFiles(path: string, onSuccess: (files: Array<{ path: string; name: string; extension: string }>) => any, onError?: (error: any) => any);
|
|
||||||
|
getEntities(path: string, onSuccess: (files: Array<{ path: string; name: string; extension: string }>) => any, onError?: (error: any) => any);
|
||||||
|
eachEntity(path: string, onSuccess: (entity: { path: string; name: string; extension: string }) => boolean, onError?: (error: any) => any);
|
||||||
|
|
||||||
fileExists(path: string): boolean;
|
fileExists(path: string): boolean;
|
||||||
folderExists(path: string): boolean;
|
folderExists(path: string): boolean;
|
||||||
concatPath(left: string, right: string): string;
|
concatPath(left: string, right: string): string;
|
||||||
|
@ -114,48 +114,38 @@ export class FileSystemAccess {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enumFiles(path: string, onSuccess: (files: Array<{ path: string; name: string; extension: string }>) => any, onError?: (error: any) => any) {
|
public eachEntity(path: string, onEntity: (file: { path: string; name: string; extension: string }) => any, onError?: (error: any) => any) {
|
||||||
try {
|
if (!onEntity) {
|
||||||
var fileManager = Foundation.NSFileManager.defaultManager();
|
return;
|
||||||
var files = fileManager.contentsOfDirectoryAtPathError(path, null);
|
|
||||||
|
|
||||||
if (!files) {
|
|
||||||
if (onError) {
|
|
||||||
onError(new Error("Failed to enum files for forlder '" + path + "'"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.enumEntities(path, onEntity, onError);
|
||||||
|
}
|
||||||
|
|
||||||
|
public getEntities(path: string, onSuccess: (files: Array<{ path: string; name: string; extension: string }>) => any, onError?: (error: any) => any) {
|
||||||
|
if (!onSuccess) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var fileInfos = new Array<{ path: string; name: string; extension: string }>();
|
var fileInfos = new Array<{ path: string; name: string; extension: string }>();
|
||||||
var file,
|
var onEntity = function (entity: { path: string; name: string; extension: string }): boolean {
|
||||||
i,
|
fileInfos.push(entity);
|
||||||
info;
|
return true;
|
||||||
|
|
||||||
|
|
||||||
for (i = 0; i < files.count(); i++) {
|
|
||||||
file = files.objectAtIndex(i);
|
|
||||||
|
|
||||||
info = {
|
|
||||||
path: this.concatPath(path, file),
|
|
||||||
name: file
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!this.folderExists(file)) {
|
|
||||||
info.extension = this.getFileExtension(info.path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fileInfos.push(info);
|
var errorOccurred;
|
||||||
}
|
var localError = function (error: any) {
|
||||||
|
|
||||||
if (onSuccess) {
|
|
||||||
onSuccess(fileInfos);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (ex) {
|
|
||||||
if (onError) {
|
if (onError) {
|
||||||
onError(ex);
|
onError(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
errorOccurred = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.enumEntities(path, onEntity, onError);
|
||||||
|
|
||||||
|
if (!errorOccurred) {
|
||||||
|
onSuccess(fileInfos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,7 +203,7 @@ export class FileSystemAccess {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.enumFiles(path, filesEnum, onError);
|
this.getEntities(path, filesEnum, onError);
|
||||||
}
|
}
|
||||||
|
|
||||||
public rename(path: string, newPath: string, onSuccess?: () => any, onError?: (error: any) => any) {
|
public rename(path: string, newPath: string, onSuccess?: () => any, onError?: (error: any) => any) {
|
||||||
@ -267,9 +257,24 @@ export class FileSystemAccess {
|
|||||||
return url.path();
|
return url.path();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: This method is the same as in the iOS implementation.
|
||||||
|
// Make it in a separate file / module so it can be reused from both implementations.
|
||||||
private getFileExtension(path: string): string {
|
private getFileExtension(path: string): string {
|
||||||
var url = Foundation.NSURL.fileURLWithPathIsDirectory(path, false);
|
// TODO [For Panata]: The definitions currently specify "any" as a return value of this method
|
||||||
return url.pathExtension();
|
//var nsString = Foundation.NSString.stringWithString(path);
|
||||||
|
//var extension = nsString.pathExtension();
|
||||||
|
|
||||||
|
//if (extension && extension.length > 0) {
|
||||||
|
// extension = extension.concat(".", extension);
|
||||||
|
//}
|
||||||
|
|
||||||
|
//return extension;
|
||||||
|
var dotIndex = path.lastIndexOf(".");
|
||||||
|
if (dotIndex && dotIndex >= 0 && dotIndex < path.length) {
|
||||||
|
return path.substring(dotIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
private deleteEntity(path: string, onSuccess?: () => any, onError?: (error: any) => any) {
|
private deleteEntity(path: string, onSuccess?: () => any, onError?: (error: any) => any) {
|
||||||
@ -284,4 +289,50 @@ export class FileSystemAccess {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private enumEntities(path: string, callback: (entity: { path: string; name: string; extension: string }) => boolean, onError?: (error) => any) {
|
||||||
|
try {
|
||||||
|
var fileManager = Foundation.NSFileManager.defaultManager();
|
||||||
|
var files = fileManager.contentsOfDirectoryAtPathError(path, null);
|
||||||
|
|
||||||
|
if (!files) {
|
||||||
|
if (onError) {
|
||||||
|
onError(new Error("Failed to enum files for forlder '" + path + "'"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var fileInfos = new Array<{ path: string; name: string; extension: string }>();
|
||||||
|
var file,
|
||||||
|
i,
|
||||||
|
info,
|
||||||
|
retVal;
|
||||||
|
|
||||||
|
|
||||||
|
for (i = 0; i < files.count(); i++) {
|
||||||
|
file = files.objectAtIndex(i);
|
||||||
|
|
||||||
|
info = {
|
||||||
|
path: this.concatPath(path, file),
|
||||||
|
name: file
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!this.folderExists(file)) {
|
||||||
|
info.extension = this.getFileExtension(info.path);
|
||||||
|
}
|
||||||
|
|
||||||
|
retVal = callback(info);
|
||||||
|
if (retVal != undefined && !retVal) {
|
||||||
|
// the callback returned false meaning we should stop the iteration
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (ex) {
|
||||||
|
if (onError) {
|
||||||
|
onError(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user