Skip to content

Commit

Permalink
feat(file): add system paths
Browse files Browse the repository at this point in the history
  • Loading branch information
ihadeed committed Mar 2, 2017
1 parent 97cf22e commit f0e2195
Showing 1 changed file with 78 additions and 4 deletions.
82 changes: 78 additions & 4 deletions src/plugins/file.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Plugin, pluginWarn } from './plugin';
import {CordovaProperty, Plugin, pluginWarn} from './plugin';

declare var window: any;
declare var cordova: any;
Expand Down Expand Up @@ -350,9 +350,9 @@ export declare var FileError: {
* ```
* import { File } from 'ionic-native';
*
* declare var cordova: any;
* const fs:string = cordova.file.dataDirectory;
* File.checkDir(this.fs, 'mydir').then(_ => console.log('yay')).catch(err => console.log('boooh'));
* const dataDirectory: string = File.dataDirectory;
*
* File.checkDir(dataDirectory, 'mydir').then(_ => console.log('yay')).catch(err => console.log('boooh'));
* ```
*
* This plugin is based on several specs, including : The HTML5 File API http://www.w3.org/TR/FileAPI/
Expand All @@ -367,6 +367,80 @@ export declare var FileError: {
repo: 'https://github.com/apache/cordova-plugin-file'
})
export class File {

/**
* Read-only directory where the application is installed.
*/
@CordovaProperty
static applicationDirectory: string;

/**
* Read-only directory where the application is installed.
*/
@CordovaProperty
static applicationStorageDirectory: string;

/**
* Where to put app-specific data files.
*/
@CordovaProperty
static dataDirectory: string;

/**
* Cached files that should survive app restarts.
* Apps should not rely on the OS to delete files in here.
*/
@CordovaProperty
static cacheDirectory: string;

/**
* Android: the application space on external storage.
*/
@CordovaProperty
static externalApplicationStorageDirectory: string;

/**
* Android: Where to put app-specific data files on external storage.
*/
@CordovaProperty
static externalDataDirectory: string;

/**
* Android: the application cache on external storage.
*/
@CordovaProperty
static externalCacheDirectory: string;

/**
* Android: the external storage (SD card) root.
*/
@CordovaProperty
static externalRootDirectory: string;

/**
* iOS: Temp directory that the OS can clear at will.
*/
@CordovaProperty
static tempDirectory: string;

/**
* iOS: Holds app-specific files that should be synced (e.g. to iCloud).
*/
@CordovaProperty
static syncedDataDirectory: string;

/**
* iOS: Files private to the app, but that are meaningful to other applications (e.g. Office files)
*/
@CordovaProperty
static documentsDirectory: string;

/**
* BlackBerry10: Files globally available to all apps
*/
@CordovaProperty
static sharedDirectory: string;

static cordovaFileError: {} = {
1: 'NOT_FOUND_ERR',
2: 'SECURITY_ERR',
Expand Down

0 comments on commit f0e2195

Please sign in to comment.