diff options
author | Ananya Sen | 2012-02-02 12:37:29 -0800 |
---|---|---|
committer | Ananya Sen | 2012-02-02 12:37:29 -0800 |
commit | 0e595c4e11ce9b44eff157de8616ed15fcd5d6fc (patch) | |
tree | aba0df7f15b631345b9c44b6b50884d06b7a803a /js/io/utils | |
parent | 87e247e74040b5e80ff40003d233d5317881102a (diff) | |
download | ninja-0e595c4e11ce9b44eff157de8616ed15fcd5d6fc.tar.gz |
refactoring some file names and locations,
change made to maintain only one codemirror div.
Signed-off-by: Ananya Sen <Ananya.Sen@motorola.com>
Diffstat (limited to 'js/io/utils')
-rw-r--r-- | js/io/utils/file-utils.js | 76 |
1 files changed, 0 insertions, 76 deletions
diff --git a/js/io/utils/file-utils.js b/js/io/utils/file-utils.js deleted file mode 100644 index 784ecf59..00000000 --- a/js/io/utils/file-utils.js +++ /dev/null | |||
@@ -1,76 +0,0 @@ | |||
1 | /* <copyright> | ||
2 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> | ||
3 | No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> | ||
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | ||
5 | </copyright> */ | ||
6 | |||
7 | var Montage = require("montage/core/core").Montage, | ||
8 | Component = require("montage/ui/component").Component; | ||
9 | |||
10 | var FileUtils = exports.FileUtils = Montage.create(Component, { | ||
11 | |||
12 | /*** | ||
13 | * checks for valid uri pattern | ||
14 | * also flags if Windows uri pattern and Unix uri patterns are mixed | ||
15 | */ | ||
16 | isValidUri:{ | ||
17 | value: function(uri){ | ||
18 | var isWindowsUri=false, isUnixUri=false,status=false; | ||
19 | if(uri !== ""){ | ||
20 | uri = uri.replace(/^\s+|\s+$/g,""); // strip any leading or trailing spaces | ||
21 | |||
22 | //for local machine folder uri | ||
23 | isWindowsUri = /^([a-zA-Z]:)(\\[^<>:"/\\|?*]+)*\\?$/gi.test(uri); | ||
24 | isUnixUri = /^(\/)?(\/(?![.])[^/]*)*\/?$/gi.test(uri);//folders beginning with . are hidden on Mac / Unix | ||
25 | status = isWindowsUri || isUnixUri; | ||
26 | if(isWindowsUri && isUnixUri){status = false;} | ||
27 | } | ||
28 | return status; | ||
29 | } | ||
30 | }, | ||
31 | |||
32 | /*** | ||
33 | * file name validation | ||
34 | */ | ||
35 | isValidFileName:{ | ||
36 | value: function(fileName){ | ||
37 | var status = false; | ||
38 | if(fileName !== ""){ | ||
39 | fileName = fileName.replace(/^\s+|\s+$/g,""); | ||
40 | status = !(/[/\\]/g.test(fileName)); | ||
41 | if(status && navigator.userAgent.indexOf("Macintosh") != -1){//for Mac files beginning with . are hidden | ||
42 | status = !(/^\./g.test(fileName)); | ||
43 | } | ||
44 | } | ||
45 | return status; | ||
46 | } | ||
47 | }, | ||
48 | |||
49 | /*** | ||
50 | * check if the file exists | ||
51 | */ | ||
52 | checkFileExists:{ | ||
53 | value: function(fileUri, folderUri, fileType){ | ||
54 | var uri = "", response=null, status=true; | ||
55 | |||
56 | //prepare absolute uri | ||
57 | if(/[^/\\]$/g.test(folderUri)){ | ||
58 | folderUri = folderUri + "/"; | ||
59 | } | ||
60 | |||
61 | //todo:add file extension check if fileType present | ||
62 | |||
63 | uri = ""+folderUri+fileUri; | ||
64 | |||
65 | response = this.application.ninja.coreIoApi.fileExists({"uri":uri}); | ||
66 | if(!!response && response.success && (response.status === 204)){ | ||
67 | status = true; | ||
68 | }else if(!!response && response.success && (response.status === 404)){ | ||
69 | status = false; | ||
70 | }else{ | ||
71 | status = false; | ||
72 | } | ||
73 | return status; | ||
74 | } | ||
75 | } | ||
76 | }); \ No newline at end of file | ||