ResourceOps.ts 802 B

1234567891011121314151617181920212223242526272829303132
  1. import EditorEvents = require("../editor/EditorEvents");
  2. class ResourceOps extends Atomic.ScriptObject {
  3. }
  4. var resourceOps = new ResourceOps();
  5. export function CreateNewFolder(resourcePath: string, reportError: boolean = true): boolean {
  6. var title = "New Folder Error";
  7. var fs = Atomic.getFileSystem();
  8. if (fs.dirExists(resourcePath) || fs.fileExists(resourcePath)) {
  9. if (reportError)
  10. resourceOps.sendEvent(EditorEvents.ModalError, { title: title, message: "Already exists: " + resourcePath });
  11. return false;
  12. }
  13. if (!fs.createDir(resourcePath)) {
  14. if (reportError)
  15. resourceOps.sendEvent(EditorEvents.ModalError, { title: title, message: "Could not create " + resourcePath });
  16. return false;
  17. }
  18. return true;
  19. }