/*
Returns a string representation of the current state of the
folder (exists, symbolic link, does not exist, etc.
962434
function() {
                var absPath = _path.resolve(_folderPath);
                if (!_fs.existsSync(absPath)) {
                    return '[DOES NOT EXIST]';
                } else {
                    var stats = _fs.lstatSync(absPath);
                    if (stats.isDirectory()) {
                        return '[DIR]';
                    } else if (stats.isSymbolicLink()) {
                        return '[LINK]';
                    } else {
                        return '[FILE]';
                    }
                }
            }
765699
function() {
			// remove any query string
			var cleaned = this.clean(),
				// get the last /
				last = cleaned.lastIndexOf('/'),
			    // if there is a last /, get everything up to that point
				dir = (last != -1) ? cleaned.substring(0, last) : '';
			// make sure we aren't left with just https/ or file:/
			return /^(https?:\/|file:\/)$/.test(dir) ? cleaned : dir;
		}
794446
function (serverRelativeUrl/*string*/) {
			var dfd = $.Deferred();

			folderExists(serverRelativeUrl).done(function (folder) {
				if (folder == false) {

					var parentFolders = pathSteps(serverRelativeUrl);
					var parentFolderPath = parentFolders[1];
					var bits = serverRelativeUrl.split("/");
					var name = bits[bits.length - 1];
					ensureFolder(parentFolderPath).done(function () /*parentSpFolder*/ {
						createFolder(name, parentFolderPath).done(function (folder) {
							dfd.resolve(folder);
						});
					});
				} else {
					dfd.resolve(folder);
				}
			});
			return dfd.promise();
		}
1323427
def existingDirectory(string):
    
    if not os.path.isdir(string):
        argparse.ArgumentTypeError('{} is not a valid directory.'.format(string))
    return string
917529
private String getContenFileName() {
        final String file  = this.content.getPath();
        if(file.indexOf('/') != -1){
            return file.substring(file.lastIndexOf('/'));
        }
        return file;
    }
956640
function getDirectoriesInURL()
{
	var trail = document.location.pathname.split( PATH_SEPARATOR );

	// check whether last section is a file or a directory
	var lastcrumb = trail[trail.length-1];
	for( var i = 0; i < FILE_EXTENSIONS.length; i++ )
	{
		if( lastcrumb.indexOf( FILE_EXTENSIONS[i] ) )
		{
			// it is, remove it and send results
			return trail.slice( 1, trail.length-1 );
		}
	}

	// it's not; send the trail unmodified
	return trail.slice( 1, trail.length );
}
957820
function(path) {
        if (typeof path !== 'string') {
            throw 'Input path must be a valid string';
        }
        var _folderName;
        var _folderPath;
        var _subFolders = [];

        _folderName = _path.basename(path);
        _folderPath = _path.join(_path.dirname(path), _folderName) + '/';

        var folderObj = {
            /*
             * Returns the name of the folder.
             */
            getName: function() {
                return _folderName;
            },

            /*
             * Returns the path of the folder.
             */
            getPath: function() {
                return _folderPath;
            },

            /*
             * Returns the absolute path of the folder.
             */
            getAbsolutePath: function() {
                return _path.resolve(_folderPath);
            },

            /*
             * Adds a sub folder to the current folder.
             */
            addSubFolder: function(folderName) {
                if (typeof folderName !== 'string' || folderName.match(/[\\\/]/)) {
                    throw 'Sub folder name must be a valid string without delimiters.';
                }
                var subFolderPath = _path.join(_folderPath, folderName);
                var subFolder = mod.createFolder(subFolderPath);
                _subFolders[folderName] = subFolder;

                return subFolder;
            },

            /*
             * Returns a reference to an existing sub folder, provided it
             * has been created via the addSubFolder method.
             */
            getSubFolder: function(folderName) {
                return _subFolders[folderName];
            },

            /*
             * Returns the path of the specified child item, relative to the
             * current folder.
             */
            getChildPath: function(subPath, tokenMap, ignoreRegex) {
                if (typeof subPath !== 'string' || subPath.length === 0) {
                    return _folderPath;
                }
                tokenMap = tokenMap || {};
                ignoreRegex = !! ignoreRegex;

                var transform = _utils.getTransformer(tokenMap, ignoreRegex);
                subPath = transform(subPath);
                return _path.join(_folderPath, subPath);
            },

            /*
             * Gets a string glob that can be used to match all
             * folders/files in the current folder and all sub folders,
             * optionally filtered by file extension.
             */
            allFilesPattern: function(extension) {
                extension = (extension && '*.' + extension) || '*';
                return _folderPath + '**/' + extension;
            },

            /* 
             * Returns a string representation of the current state of the
             * folder (exists, symbolic link, does not exist, etc.
             */
            getStatus: function() {
                var absPath = _path.resolve(_folderPath);
                if (!_fs.existsSync(absPath)) {
                    return '[DOES NOT EXIST]';
                } else {
                    var stats = _fs.lstatSync(absPath);
                    if (stats.isDirectory()) {
                        return '[DIR]';
                    } else if (stats.isSymbolicLink()) {
                        return '[LINK]';
                    } else {
                        return '[FILE]';
                    }
                }
            },

            /*
             * Ensures that a physical copy of the folder exists at the path
             * represented by this folder.
             */
            ensureFolder: function() {
                var def = _promise.deferred();

                _fs.exists(_folderPath, function(exists) {
                    if (exists) {
                        def.resolve();
                    } else {
                        _fs.mkdir(_folderPath, function(err) {
                            if (!err) {
                                def.resolve();
                            } else {
                                def.reject();
                            }
                        });
                    }
                });

                return def.promise();
            },

            /*
             * Ensures that the current folder and all of its defined subtrees
             * exist on the file system.
             */
            ensureFolderTree: function() {
                var def = _promise.deferred();

                folderObj.ensureFolder().success(function() {
                    var subFolderCount = 0;
                    for (var folderName in _subFolders) {
                        subFolderCount++;
                    }

                    if (subFolderCount > 0) {
                        var resolver = def.getMultiStepResolver(subFolderCount);
                        for (var folderName in _subFolders) {
                            _subFolders[folderName].ensureFolderTree()
                                .success(function() {
                                    resolver.stepComplete();
                                }).fail(function() {
                                    resolver.reject();
                                });
                        }
                    } else {
                        def.resolve();
                    }
                });

                return def.promise();
            }
        };

        return folderObj;
    }
792878
function(exists, linkString, callback) {
      if (exists) {
        return callback(null, symlink);
      }
      fs.symlink(linkString, _toFile, function(err) {
        callback(err, symlink);
      });
    }
215535
function() {
        // Folder
        var folder = this.createElementNS(this.kmlns, "Folder");

        // Folder name
        if (this.foldersName) {
            var folderName = this.createElementNS(this.kmlns, "name");
            var folderNameText = this.createTextNode(this.foldersName); 
            folderName.appendChild(folderNameText);
            folder.appendChild(folderName);
        }

        // Folder description
        if (this.foldersDesc) {
            var folderDesc = this.createElementNS(this.kmlns, "description");        
            var folderDescText = this.createTextNode(this.foldersDesc); 
            folderDesc.appendChild(folderDescText);
            folder.appendChild(folderDesc);
        }

        return folder;
    }
391611
public String getValueString() {
		if (current == State.KEY) {
			return valueStr;
		} else if (current == State.VALUE_STRING) {
			return valueStr;
		} else if (current == State.VALUE_NULL) {
			return null;
		} else {
			throw new IllegalStateException("unexpected state. state=" + current);
		}
	}
32286
String getSubFolderName() {
        if (subFolderName == null) {
            String relPath = getAbsolutePath().replace(REPO_ABSOLUTE_PATH, "");
            relPath = relPath.substring(relPath.indexOf(SystemUtils.FILE_SEPARATOR) + 1);
            String[] parts = relPath.split("[\\\\/]");
            subFolderName = ((parts.length < 3) || (StringUtils.isBlank(parts[1]))) ? "" : parts[1];
        }
        return subFolderName;
    }
1007317
def result_str(self):
        
        return '{}, {}, {}'.format(LocalOnlyCounter.plural_fmt('project', self.projects),
                                   LocalOnlyCounter.plural_fmt('folder', self.folders),
                                   LocalOnlyCounter.plural_fmt('file', self.files))
460111
public String getRootFolder() {

        String folder = "/";
        if (getSettings().getUserSettings().getRestrictExplorerView()) {
            folder = getSettings().getUserSettings().getStartFolder();
        }
        try {
            getCms().readFolder(folder, CmsResourceFilter.IGNORE_EXPIRATION);
            return folder;
        } catch (CmsException e) {
            // should usually never happen
            if (LOG.isInfoEnabled()) {
                LOG.info(e);
            }
            return "/";
        }
    }
1240720
def currentFolder(self, value):
        """"""
        if value in self.folders:
            if value.lower() != 'root':
                self._currentFolder = value
                self._location = "%s/%s" % (self.root, value)
            else:
                self._currentFolder = value
                self._location = self.root
            self.__init(folder=value)
305043
function (file) {
	var folder = path.dirname(file) + '/' + path.basename( file, '.json' );
	return fs.existsSync(folder) && isDir(folder) ? folder : false;
}
1356415
private static String fileStatusToString(FileStatus stat) {
    assert stat != null;

    return String.format(
        "path: %s, isDir: %s, len: %d, owner: %s",
        stat.getPath().toString(),
        stat.isDir(),
        stat.getLen(),
        stat.getOwner());
  }
938116
String getPathName(boolean url) {
        if (pathName == null || pathName.isEmpty()) {
            VirtualFile[] path = getParentFiles();
            final StringBuilder builder = new StringBuilder(path.length * 30 + 50);
            for (int i = path.length - 1; i > -1; i--) {
                final VirtualFile parent = path[i].parent;
                if (parent == null) {
                    builder.append(path[i].name);
                } else {
                    if (parent.parent != null) {
                        builder.append('/');
                    }
                    builder.append(path[i].name);
                }
            }
            pathName = builder.toString();
        }
        // Perhaps this should be cached to avoid the fs stat call?
        return (url && isDirectory()) ? pathName.concat("/") : pathName;
    }