forked from MiguelCastillo/Brackets-Ternific
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProjectFiles.js
More file actions
56 lines (42 loc) · 1.47 KB
/
Copy pathProjectFiles.js
File metadata and controls
56 lines (42 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/**
* Ternific Copyright (c) 2014 Miguel Castillo.
*
* Licensed under MIT
*/
define(function (require, exports, module) {
"use strict";
var spromise = require("libs/js/spromise"),
FileStream = require("FileStream"),
ProjectManager = brackets.getModule("project/ProjectManager"),
FileSystem = brackets.getModule("filesystem/FileSystem");
function ProjectFiles() {
}
ProjectFiles.prototype.openFile = function(fileName, forceCreate) {
var deferred = spromise.defer();
var filePath = this.currentProject.fullPath;
var handle = FileSystem.getFileForPath(filePath + fileName);
return spromise(function(resolve, reject) {
handle.exists(function(err, exists) {
if (err) {
reject(err);
}
else {
resolve(new FileStream({
handle: handle,
fileName: fileName,
filePath: filePath
}));
}
});
});
};
ProjectFiles.prototype.resolveName = function(fileName) {
return this.currentProject.fullPath + fileName;
};
var _projectFiles = new ProjectFiles();
$(ProjectManager).on("projectOpen", function(e, project){
_projectFiles.currentProject = project;
$(_projectFiles).trigger('projectOpen', [project]);
});
return _projectFiles;
});