How to use the ext/filesystem/filesystem.exists function in ext

To help you get started, we’ve selected a few ext examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pylonide / pylon / client / ext / uploadfiles / uploadfiles.js View on Github external
upload(file);
                    }
                }
                
                function upload(file) {
                    var file = file || _self.currentFile;
                    var node = file.queueNode;
                    apf.xmldb.setAttribute(node, "progress", 0);
                    
                    if (!_self.worker)
                        _self.initWorker();
                    _self.worker.postMessage({cmd: 'connect', id: file.name, file: file, path: file.path});
                }
                _self.upload = upload;
                
                fs.exists(file.path + "/" + file.name, checkFileExists);
            }
        }
        // no files in queue, upload completed
        else {
            _self.uploadInProgress = false;
            _self.existingOverwriteAll = false;
            _self.existingSkipAll = false;
            (davProject.realWebdav || davProject).setAttribute("showhidden", require('ext/settings/settings').model.queryValue("auto/projecttree/@showhidden"));
            
            this.hideUploadActivityTimeout = setTimeout(function() {
                mdlUploadActivity.load("<data>");
                boxUploadActivity.hide();
            }, 5000);
        }
    },
    </data>
github pylonide / pylon / plugins / cloud9.client.ext.autosave / autosave / autosave.js View on Github external
ide.addEventListener("afteropenfile", function(data) {
            if (!data || !data.doc)
                return;

            var node = data.doc.getNode();
            var dateOriginal = new Date(node.getAttribute("modifieddate"));
            var bkpPath = getTempPath(node.getAttribute("path"));

            // If there is already a backup file
            fs.exists(bkpPath, function(exists) {
                if (!exists)
                    return;

                fs.list(bkpPath, function(xml, depth, fileObj) {
                    var date;
                    if (fileObj.data.parentNode.lastModified)
                        date = new Date(fileObj.data.parentNode.lastModified);

                    // If the date of the backed up file is newer than the file we
                    // are trying to open, present the user with a choice dialog
                    if (date && date.getTime() > dateOriginal.getTime()) {
                        ext.initExtension(self);

                        fs.readFile(bkpPath, function(contents) {
                            // Set up some state into the window itself. Not great,
                            // but easiest way and not too awful
github pylonide / pylon / plugins-client / ext.vim / cli.js View on Github external
e: function(editor, data) {
        var path = data.argv[1];
        if (!path) {
            gotofile.toggleDialog(1);
            return false;
        }
        else {
            path = (ide.davPrefix + "/" + path).replace(/\/+/, "/");
            filesystem.exists(path, function(exists){
                if (exists) {
                    editors.gotoDocument({path: path});
                }
                else {
                    var node = filesystem.createFileNodeFromPath(path);
                    node.setAttribute("newfile", "1");
                    node.setAttribute("changed", "1");
                    node.setAttribute("cli", "1"); // blocks Save As dialog

                    var doc = ide.createDocument(node);
                    doc.cachedValue = "";

                    editors.gotoDocument({
                        doc: doc,
                        type: "newfile",
                        origin: "newfile"
github pylonide / pylon / plugins-client / ext.vim / cli.js View on Github external
e: function(editor, data) {
        var path = data.argv[1];
        if (!path) {
            gotofile.toggleDialog(1);
            return false;
        }
        else {
            path = (ide.davPrefix + "/" + path).replace(/\/+/, "/");
            filesystem.exists(path, function(exists){
                if (exists) {
                    editors.gotoDocument({path: path});
                }
                else {
                    var node = filesystem.createFileNodeFromPath(path);
                    node.setAttribute("newfile", "1");
                    node.setAttribute("changed", "1");
                    node.setAttribute("cli", "1"); // blocks Save As dialog

                    var doc = ide.createDocument(node);
                    doc.cachedValue = "";

                    editors.gotoDocument({
                        doc: doc,
                        type: "newfile",
                        origin: "newfile"
github pylonide / pylon / plugins-client / ext.save / save.js View on Github external
self._saveAsNoUI(page, path, newPath, isReplace);

            if (window.winConfirm) {
                winConfirm.hide();
                
                if (self["btnConfirmOk"] && btnConfirmOk.caption == "Yes")
                    btnConfirmOk.setCaption("Ok");
            }
        };
        
        var doCancel = function() {
            if (window.winConfirm && btnConfirmOk.caption == "Yes")
                btnConfirmOk.setCaption("Ok");
        };
        if (path !== newPath || parseInt(file.getAttribute("newfile") || 0, 10) === 1) {
            fs.exists(newPath, function (exists) {
                if (exists) {
                    var name = newPath.match(/\/([^/]*)$/)[1];
                    var folder = newPath.match(/\/([^/]*)\/[^/]*$/)[1];
                    
                    isReplace = true;
                    util.confirm(
                        "A file with this name already exists",
                        "\"" + name + "\" already exists, do you want to replace it?",
                        "A file with the same name already exists at this location." +
                        "Selecting Yes will overwrite the existing document.",
                        doSave,
                        doCancel);
                    btnConfirmOk.setCaption("Yes");
                }
                else {
                    doSave();
github pylonide / pylon / client / ext / dragdrop / dragdrop.js View on Github external
if(!strXml)
                    next();
                    
                strXml = strXml[1]
                var oXml = apf.xmldb.appendChild(node, apf.getXml(strXml));

                trFiles.select(oXml);
                if (file.size &lt; MAX_OPENFILE_SIZE)
                    ide.dispatchEvent("openfile", {doc: ide.createDocument(oXml)});
                
                next();
            });
        }
        
        /** Check if path already exists, otherwise continue with upload() */
        fs.exists(path + "/" + file.name, check);
    },
github pylonide / pylon / plugins / cloud9.client.ext.autosave / autosave / autosave.js View on Github external
var removeFile = function(path) {
    fs.exists(path, function(exists) {
        if (exists)
            fs.remove(path);
    });
};
github pylonide / pylon / client / ext / nodeunit / nodeunit.js View on Github external
var recur = function(){
            stack.push(path.shift());

            if (path.length == 0) {
                newresource.newfile("_test.js", _self.template,
                  ide.davPrefix + "/");
                return;
            }

            fs.exists(stack.join("/") + "/" + path[0], function(data, state, extra){
                if (data) {
                    recur();
                }
                else {
                    fs.webdav.exec("mkdir",
                      [stack.join("/"), path[0]], function(data) {
                        recur();
                    });
                }
            });
        }