Throws if the given file is null, is not a file or directory, or is an empty directory.
166254
public static void checkFileOrDirectoryToBeRead(File fileOrDir, String fileDesc)
    {
        if (fileOrDir == null)
            throw new IllegalArgumentException(fileDesc + " must not be null.");
        if (!fileOrDir.exists())
            throw new IllegalArgumentException(fileDesc + " does not exist: " + fileOrDir.getAbsolutePath());
        if (!(fileOrDir.isDirectory() || fileOrDir.isFile()))
            throw new IllegalArgumentException(fileDesc + " must be a file or a directory: " + fileOrDir.getPath());
        if (fileOrDir.isDirectory())
        {
            if (fileOrDir.list().length == 0)
                throw new IllegalArgumentException(fileDesc + " is an empty directory: " + fileOrDir.getPath());
        }
    }
872574
function isEmpty( value ) {
  return isUndefined( value ) ||
         value === null ||
         isString( value ) &&
         value.length <= 0 ||
         ( /^\s*$/ ).test( value );
}
327707
function _isDirectory (directory, callback) {

			if ("undefined" === typeof directory) {
				throw new ReferenceError("missing \"directory\" argument");
			}
				else if ("string" !== typeof directory) {
					throw new TypeError("\"directory\" argument is not a string");
				}
				else if ("" === directory.trim()) {
					throw new Error("\"directory\" argument is empty");
				}
			else if ("undefined" === typeof callback) {
				throw new ReferenceError("missing \"callback\" argument");
			}
				else if ("function" !== typeof callback) {
					throw new TypeError("\"callback\" argument is not a function");
				}
			else {

				lstat(directory, (err, stats) => {
					return callback(null, Boolean(!err && stats.isDirectory()));
				});

			}

		}
1161963
public static void checkValidDir(final File dir) {
        checkNotNull("dir", dir);
        if (!dir.exists()) {
            throw new IllegalArgumentException("The directory '" + dir + "' does not exist!");
        }
        if (!dir.isDirectory()) {
            throw new IllegalArgumentException("The name '" + dir + "' is not a directory!");
        }
    }
1133486
private @Nullable StatFs updateStatsHelper(@Nullable StatFs statfs, @Nullable File dir) {
    if(dir == null || !dir.exists()) {
      // The path does not exist, do not track stats for it.
      return null;
    }

    try {
      if (statfs == null) {
        // Create a new StatFs object for this path.
        statfs = createStatFs(dir.getAbsolutePath());
      } else {
        // Call restat and keep the existing StatFs object.
        statfs.restat(dir.getAbsolutePath());
      }
    } catch (IllegalArgumentException ex) {
      // Invalidate the StatFs object for this directory. The native StatFs implementation throws
      // IllegalArgumentException in the case that the statfs() system call fails and it invalidates
      // its internal data structures so subsequent calls against the StatFs object will fail or
      // throw (so we should make no more calls on the object). The most likely reason for this call
      // to fail is because the provided path no longer exists. The next call to updateStats() will
      // a new statfs object if the path exists. This will handle the case that a path is unmounted
      // and later remounted (but it has to have been mounted when this object was initialized).
      statfs = null;
    } catch (Throwable ex) {
      // Any other exception types are not expected and should be propagated as runtime errors.
      throw Throwables.propagate(ex);
    }

    return statfs;
  }
76219
private File searchFile(File directory, String pattern) {
        if (!directory.isDirectory()) {
            throw new IllegalArgumentException("Not a directly: "+directory);
        }
        File[] files = directory.listFiles();
        assert files != null; //checked for directly above.
        for (File file : files) {
            if (file.getName().matches(pattern)) return file;
        }
        return null;
    }
229204
public static boolean isInSubDirectory(File dir, File file)
    {
        if (file == null)
            return false;

        if (file.equals(dir))
            return true;

        return isInSubDirectory(dir, file.getParentFile());
    }
922162
public T addFile(String file) {
    checkNotNull(file, "file");
    builder.files.add(file);
    return self();
  }
1111865
public static String nullIfEmpty(String value) {
		return value==null || value.isEmpty() ? null : value;
	}
1088511
public static boolean isEmpty(Object value) {
		return (null == value || (value instanceof String && StrUtil.isEmpty((String) value)));
	}
1306968
@Override
    public T fromFile(final File file) throws IllegalArgumentException, DescriptorImportException {
        // Precondition checks
        if (file == null) {
            throw new IllegalArgumentException("File not specified");
        }

        // Delegate
        try {
            return this.fromStream(new FileInputStream(file));
        } catch (final FileNotFoundException e) {
            throw new IllegalArgumentException("Specified file does not exist or is a directory: "
                + file.getAbsolutePath());
        }
    }
778323
public static void checkNotNull(Object o, String msg, int arg1) {
        if (o == null) {
            throwNullPointerEx(msg, arg1);
        }
    }
290681
def is_empty(bam_file):
    
    bam_file = objectstore.cl_input(bam_file)
    cmd = ("set -o pipefail; "
           "samtools view {bam_file} | head -1 | wc -l")
    p = subprocess.Popen(cmd.format(**locals()), shell=True,
                         executable=do.find_bash(),
                         stdout=subprocess.PIPE, stderr=subprocess.PIPE,
                         preexec_fn=lambda: signal.signal(signal.SIGPIPE, signal.SIG_DFL))
    stdout, stderr = p.communicate()
    stdout = stdout.decode()
    stderr = stderr.decode()
    if ((p.returncode == 0 or p.returncode == 141) and
         (stderr == "" or (stderr.startswith("gof3r") and stderr.endswith("broken pipe")))):
        return int(stdout) == 0
    else:
        raise ValueError("Failed to check empty status of BAM file: %s" % str(stderr))
672365
public final boolean isFileExcludedByExtension(@Nullable final File file) {
    return file == null || !file.isFile() || this.excludeExtensions.contains(PreprocessorUtils.getFileExtension(file));
  }
790974
function fileExists(file) {
    try {
        var targetStat = fs.statSync(file);
        if (targetStat.isDirectory() ) {
            throw new Error("File exists but it's a driectory: " + file);
        }
    }
    catch(err) {
        if (err.code == 'ENOENT') {         // No such file or directory
            return false;
        }
        else {
            throw err;
        }
    }
    return true;
}
309990
@Override
    public FileItem file(String name) {
        for (FileItem item : request.getFiles()) {
            // FileItem that do not have an real file attached, should not be returned
            if (item.field().equals(name) && !Strings.isNullOrEmpty(item.name())) {
                return item;
            }
        }
        return null;
    }
682140
public static void checkNotNullOrEmpty(String string, String message) {
    if (string == null || string.isEmpty()) {
      throw new IllegalArgumentException(message);
    }
  }