diff options
author | Ananya Sen | 2012-01-31 06:24:03 -0800 |
---|---|---|
committer | Ananya Sen | 2012-01-31 06:24:03 -0800 |
commit | 906776893138257f96a0530674eda456ca3d817b (patch) | |
tree | 413e8b87424cb038a09df1d78eea7efd9cbfd3fc | |
parent | 63bfd3bd4a3165d83893c67cd4e6442a4794c0fb (diff) | |
download | ninja-906776893138257f96a0530674eda456ca3d817b.tar.gz |
added the api to check if a file is writable
Signed-off-by: Ananya Sen <Ananya.Sen@motorola.com>
-rwxr-xr-x | js/io/system/coreioapi.js | 47 |
1 files changed, 1 insertions, 46 deletions
diff --git a/js/io/system/coreioapi.js b/js/io/system/coreioapi.js index 1585fc33..c99ebda7 100755 --- a/js/io/system/coreioapi.js +++ b/js/io/system/coreioapi.js | |||
@@ -837,50 +837,7 @@ exports.CoreIoApi = Montage.create(Component, { | |||
837 | var serviceURL = this._prepareServiceURL(this.fileServiceURL, file.uri), | 837 | var serviceURL = this._prepareServiceURL(this.fileServiceURL, file.uri), |
838 | xhr = new XMLHttpRequest(); | 838 | xhr = new XMLHttpRequest(); |
839 | xhr.open("GET", serviceURL, false); | 839 | xhr.open("GET", serviceURL, false); |
840 | xhr.setRequestHeader("get-attributes", "true"); | 840 | xhr.setRequestHeader("get-file-info", "true"); |
841 | xhr.send(); | ||
842 | if (xhr.readyState === 4) { | ||
843 | retValue.status = xhr.status; | ||
844 | if(xhr.status == 200) { | ||
845 | retValue.content = xhr.responseText; | ||
846 | } | ||
847 | retValue.success = true; | ||
848 | } | ||
849 | } | ||
850 | catch(error) { | ||
851 | xhr = null; | ||
852 | retValue.success = false; | ||
853 | } | ||
854 | } | ||
855 | return retValue; | ||
856 | } | ||
857 | }, | ||
858 | |||
859 | //////////////////////////////////////////////////////////////////// | ||
860 | // Checks if the directory is writable | ||
861 | // Parameters: | ||
862 | // the file parameter must contain the following properties | ||
863 | // uri: string value containing the full directory path/URI i.e. "c:/foo" | ||
864 | // | ||
865 | // Return values: | ||
866 | // returns an object with two properties | ||
867 | // success: boolean indicating if the call succeeded or failed | ||
868 | // status: int indicating the request HTTP status code | ||
869 | // 204 - The file exists and response body has writable flag | ||
870 | // 404 - the file does not exist | ||
871 | // 500 - unknown server error occurred | ||
872 | //TODO:to be finalized | ||
873 | isDirectoryWritable:{ | ||
874 | enumerable:true, | ||
875 | writable:false, | ||
876 | value:function(file){ | ||
877 | var retValue = { success:null, status:null }; | ||
878 | if(file && file.uri) { | ||
879 | try { | ||
880 | var serviceURL = this._prepareServiceURL(this.directoryServiceURL, file.uri), | ||
881 | xhr = new XMLHttpRequest(); | ||
882 | xhr.open("GET", serviceURL, false); | ||
883 | xhr.setRequestHeader("get-attributes", "true"); | ||
884 | xhr.send(); | 841 | xhr.send(); |
885 | if (xhr.readyState === 4) { | 842 | if (xhr.readyState === 4) { |
886 | retValue.status = xhr.status; | 843 | retValue.status = xhr.status; |
@@ -899,8 +856,6 @@ exports.CoreIoApi = Montage.create(Component, { | |||
899 | } | 856 | } |
900 | } | 857 | } |
901 | 858 | ||
902 | |||
903 | |||
904 | }); | 859 | }); |
905 | //////////////////////////////////////////////////////////////////////// | 860 | //////////////////////////////////////////////////////////////////////// |
906 | //////////////////////////////////////////////////////////////////////// \ No newline at end of file | 861 | //////////////////////////////////////////////////////////////////////// \ No newline at end of file |