本文整理匯總了TypeScript中@ionic-native/file.File.checkDir方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript File.checkDir方法的具體用法?TypeScript File.checkDir怎麽用?TypeScript File.checkDir使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類@ionic-native/file.File
的用法示例。
在下文中一共展示了File.checkDir方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: resolve
return new Promise<string>((resolve, reject) => {
this.file.checkDir(path, directoryName).then((exists) =>{
path = path + directoryName +'/';
console.log(path + ' already exists!');
resolve(path);
}).catch(error => {
console.log('Directory does not exists! ' + error.message);
this.file.createDir(path, directoryName, false).then((result:any) =>{
path = path + directoryName + '/';
console.log('Directory: ' + path + ' created!');
resolve(path);
}).catch(error=>{
console.log('Directory creation error! ' + error.message);
resolve(path);
});
});
});
示例2: Error
const getCacheDirectory = () => {
if (!cacheDirectoryPromise) {
const basePath = FILE.cacheDirectory
const desiredPath = `${basePath}${BLOB_CACHE_DIR}/`
cacheDirectoryPromise = Bluebird.resolve(FILE.checkDir(basePath, BLOB_CACHE_DIR)).then(success => {
return desiredPath
}).catch(error => {
return FILE.createDir(basePath, BLOB_CACHE_DIR, true).then(dirEntry => {
return desiredPath
}).catch(error => {
throw new Error('Could not create blob cache directory.')
})
})
}
return cacheDirectoryPromise
}
示例3: Observable
return new Observable(observer => {
this.file.checkDir(this.file.dataDirectory, dirPath)
.then((exists) => observer.next(true))
.catch((error) => observer.next(false));
});