/* Returns with the list of file names without the extension
484811
function getFileNames(path, extension)
{
    var docPath = __dirname + '/' + path;
    var fileNames = [];
    var findPattern = new RegExp("." + extension + "$");
    var replacePattern = new RegExp("." + extension + "$","g");
    fs.readdirSync( docPath ).forEach( function(fileName ) {
        if( fileName.match( findPattern ) ) {
            fileNames.push( fileName.replace( replacePattern, "" ) );
        }
    });

    verbose && console.log('Read "' + extension + '" files from ' + docPath );

    return fileNames;
}
1189123
function _getExtension(file) {
        var ret;
        if (file) {
            var fileTypes = file.split(".");
            var len = fileTypes.length;
            if (0 === len) {
                return ret;
            }
            ret = fileTypes[len - 1];
            return ret;
        }
    }
31202
function extensionMatches (filename) {
		var extname = path.extname(filename);
		if (extname) {
			return extname === extension;
		}
		return true;
	}
317774
function(path){
      var fullPath = []; 
      try{
        var files = fs.readdirSync(path); 
        for(var i = 0; i < files.length; i++){
          fullPath.push(path + '/' + files[i]); 
        }
        return fullPath; 
      }catch(e){
        return [];
      }
    }
1288268
def strip_vl_extension(filename):
    """"""
    for ext in ['.vl.json', '.json']:
        if filename.endswith(ext):
            return filename[:-len(ext)]
    else:
        return filename
535563
@Pure
	public static String[] extensions(File filename) {
		if (filename == null) {
			return new String[0];
		}
		final String largeBasename = largeBasename(filename);
		final String[] parts = largeBasename.split(Pattern.quote(Character.toString(getFileExtensionCharacter())));
		if (parts.length <= 1) {
			return new String[0];
		}
		final String[] result = new String[parts.length - 1];
		System.arraycopy(parts, 1, result, 0, result.length);
		return result;
	}
968324
function (dir) {
    let files = [];
    let list = fs.readdirSync(dir);
    list.forEach(function (file) {
        file = dir + '/' + file;
        let stat = fs.statSync(file);
        if (stat && stat.isDirectory()) files = files.concat(walk(file));
        else files.push(file);
    });
    return files;
}
784904
function listXmlFiles(path, recursive) {
  try {
    var allFiles = recursive ? read(path) : fs.readdirSync(path);

    var xmlFiles = allFiles
      .map(function(file) {
        return fspath.join(path, file);
      })
      // Fiter out non-files
      .filter(function(file) {
        return fs.statSync(file).isFile();
      })
      // Only return files ending in '.xml'
      .filter(function(file) {
        return file.slice(-4) === ".xml";
      });
    // No files returned
    if (!xmlFiles.length > 0) {
      return new Error("No xml files found");
    } else {
      // Return the array of files ending in '.xml'
      return xmlFiles;
    }
  } catch (e) {
    throw e;
  }
}
315136
public static String getFileNameWithoutExtenxion(String fileName) {
		if (fileName==null){
			return null;
		} else {
			int number=fileName.lastIndexOf('.');
			
			if (number>=0){
				return fileName.substring(0, number);
			} else {
				return fileName;
			}
		}		
	}
112509
def _listdir(pth, extensions):
    """"""
    try:
        return [fname for fname in os.listdir(pth)
                if os.path.splitext(fname)[1] in extensions]
    except OSError:  # pragma: nocover
        pass
1160331
function (fileName) {
            fileName = (fileName || "").toLowerCase();
            var validExtensions = ["svg", "cdr", "eps", "ai"],
                fileExtension = fileName.substr(fileName.lastIndexOf('.') + 1);

            return validExtensions.indexOf(fileExtension) != -1;
        }
746855
function getFileList($rdir, $showHidden = false)
    {
        $filelist = '';
        if ($handle = opendir($rdir))
        {
            while (false !== ($file = readdir($handle)))
            {
                if ($file == '.' or $file == '..')
                {
                    continue;
                }

                if ($file{0} == "." and !$showHidden)
                {
                    continue;
                }

                $stats = stat($rdir . "/" . $file);
                if (is_dir($rdir . "/" . $file)) $mode = "d"; else $mode = "-";
                $moded = sprintf("%o", ($stats['mode'] & 000777));
                $mode1 = substr($moded, 0, 1);
                $mode2 = substr($moded, 1, 1);
                $mode3 = substr($moded, 2, 1);
                switch ($mode1) {
                    case "0":
                        $mode .= "---";
                        break;
                    case "1":
                        $mode .= "--x";
                        break;
                    case "2":
                        $mode .= "-w-";
                        break;
                    case "3":
                        $mode .= "-wx";
                        break;
                    case "4":
                        $mode .= "r--";
                        break;
                    case "5":
                        $mode .= "r-x";
                        break;
                    case "6":
                        $mode .= "rw-";
                        break;
                    case "7":
                        $mode .= "rwx";
                        break;
                }
                switch ($mode2) {
                    case "0":
                        $mode .= "---";
                        break;
                    case "1":
                        $mode .= "--x";
                        break;
                    case "2":
                        $mode .= "-w-";
                        break;
                    case "3":
                        $mode .= "-wx";
                        break;
                    case "4":
                        $mode .= "r--";
                        break;
                    case "5":
                        $mode .= "r-x";
                        break;
                    case "6":
                        $mode .= "rw-";
                        break;
                    case "7":
                        $mode .= "rwx";
                        break;
                }
                switch ($mode3) {
                    case "0":
                        $mode .= "---";
                        break;
                    case "1":
                        $mode .= "--x";
                        break;
                    case "2":
                        $mode .= "-w-";
                        break;
                    case "3":
                        $mode .= "-wx";
                        break;
                    case "4":
                        $mode .= "r--";
                        break;
                    case "5":
                        $mode .= "r-x";
                        break;
                    case "6":
                        $mode .= "rw-";
                        break;
                    case "7":
                        $mode .= "rwx";
                        break;
                }
                $uidfill = "";
                for ($i = strlen($stats['uid']); $i < 5; $i++) $uidfill .= " ";
                $gidfill = "";
                for ($i = strlen($stats['gid']); $i < 5; $i++) $gidfill .= " ";
                $sizefill = "";
                for ($i = strlen($stats['size']); $i < 11; $i++) $sizefill .= " ";
                $nlinkfill = "";
                for ($i = strlen($stats['nlink']); $i < 5; $i++) $nlinkfill .= " ";
                $mtime = date("M d H:i", $stats['mtime']);
                $filelist .= $mode . $nlinkfill . $stats['nlink'] . " " . $stats['uid'] . $uidfill . $stats['gid'] . $gidfill . $sizefill . $stats['size'] . " " . $mtime . " " . $file . "\r\n";
            }
            closedir($handle);
        }
        return $filelist;
    }
1252609
async function getFileList(dir, fileList) {
  return new Promise(async function (resolve, reject) {  
  fileList = fileList || [];
  var filesIndex = await io.getFiles(dir, null);   
  var files = io.absoluteFiles(filesIndex);
  files.forEach(function (file) {
    fileList.push(file);
  });
  resolve(fileList);
});
}
1262478
function fileExtension(name, defaultValue) {
        if (defaultValue === void 0) { defaultValue = ""; }
        var extension = defaultValue;
        if (name) {
            var idx = name.lastIndexOf(".");
            if (idx > 0) {
                extension = name.substring(idx + 1, name.length).toLowerCase();
            }
        }
        return extension;
    }
591946
public static List<File> getFilesByExtension(File dir, String[] extensions)
    {
        if (!dir.isDirectory() || extensions == null)
            return Collections.emptyList();
        List<File> files = new ArrayList<File>();
        addFilesByExtension(files, dir, extensions);
        return files;
    }
209850
function (dir, search, excludedDirs) {
        excludedDirs = excludedDirs || [];

        var result = [];
        var files = fs.readdirSync(dir);
        for (var i = 0; i < files.length; i++) {
            var fullpath = path.join(dir, files[i]);
            var stat = fs.statSync(fullpath);
            if (stat.isDirectory() && (!excludedDirs.contains(fullpath))) {
                result = result.concat(utilities.recursiveFindFiles(fullpath, search));
            }
            else if (!search || (fullpath.indexOf(search) >= 0)) {
                result.push(fullpath);
            }
        }
        return result;
    }
466399
function getFilesList(pattern) {
		//If pattern empty return all avaliable fonts
		if (pattern === undefined || pattern === '') {
			formatingFontsArray(serverFonts);
			closeConnection();
			return; // We are completed, close connection and end the program
		}

		var serverFiles = [],
			preg = new RegExp('[\\w\\-\\.]*' + pattern + '[\\w\\-\\.]*');


		function regular() {
			if (serverFonts.length < 1) {
				if (serverFiles.length !== 0){
					formatingFontsArray(serverFiles);
				}else{
					grunt.log.warn('We haven\'t any suitable fonts');
				}
				closeConnection();
				return; // We are completed, close connection and end the program
			}
			var file = serverFonts.pop();
			if (preg.test(file)) {
				serverFiles.push(file);
			}
			regular();
		}
		regular();
	}