Created
December 9, 2012 22:18
-
-
Save xcriptus/4247264 to your computer and use it in GitHub Desktop.
StarUML - Translator - Predefined functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Here comes some code that initialize some global variables | |
// This code is an excerpt of StarUML translators | |
//////////////////////////////////////////////// | |
// createFile : | |
// | |
function createFile(path) { | |
notify('Creating file '+ path + '...'); | |
return fileObject.CreateTextFile(path, true, false); | |
} | |
///////////////////////////////////////////////// | |
// deleteFile : | |
// | |
function deleteFile(path) { | |
notify('Deleting file '+ path + '...'); | |
fileObject.DeleteFile(path, false); | |
} | |
///////////////////////////////////////////////// | |
// createFolder : | |
// | |
function createFolder(path) { | |
notify('Creating folder '+ path + '...'); | |
return fileObject.CreateFolder(path); | |
} | |
///////////////////////////////////////////////// | |
// deleteFolder : | |
// | |
function deleteFolder(path) { | |
notify('Deleting folder '+ path + '...'); | |
fileObject.deleteFolder(path); | |
} | |
///////////////////////////////////////////////// | |
// fileExists : | |
// | |
function fileExists(path) { | |
return fileObject.FileExists(path); | |
} | |
///////////////////////////////////////////////// | |
// fileExists : | |
// | |
function folderExists(path) { | |
return fileObject.FolderExists(path); | |
} | |
///////////////////////////////////////////////// | |
// fileBegin : | |
// | |
function fileBegin(path) { | |
fileExceptionOccurred = false; | |
try | |
{ | |
var cs; | |
if (fileExists(path)) { | |
cs = fileObject.CreateTextFile(path, true, false); | |
} else { | |
var ep = path.lastIndexOf("\\"); | |
if (ep > -1) { | |
var folder = path.substr(0, ep); | |
if (!folderExists(folder)) | |
createFolder(folder); | |
} | |
cs = createFile(path); | |
} | |
outputStreamStack.push(os); | |
os = cs; | |
} | |
catch (ex) | |
{ | |
fileExceptionOccurred = true; | |
} | |
} | |
///////////////////////////////////////////////// | |
// fileEnd : | |
// | |
function fileEnd() { | |
if (!fileExceptionOccurred) { | |
os.close(); | |
os = outputStreamStack.pop(); | |
} else { | |
// ...? | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment