Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions api/src/org/labkey/api/util/FileType.java
Original file line number Diff line number Diff line change
Expand Up @@ -490,31 +490,32 @@ public Path newFile(Path parent, String basename)
return FileUtil.appendName(parent, getName(parent, basename));
}

public boolean isType(File file)
public boolean isType(@Nullable File file)
{
return isType(file, null, null);
}

public boolean isType(FileLike file)
public boolean isType(@Nullable FileLike file)
{
return isType(file.toNioPathForRead(), null, null);
return file != null && isType(file.toNioPathForRead(), null, null);
}

public boolean isType(java.nio.file.Path path)
public boolean isType(@Nullable java.nio.file.Path path)
{
return isType(path, null, null);
}

public boolean isType(java.nio.file.Path path, String contentType, byte[] header)
public boolean isType(@Nullable java.nio.file.Path path, @Nullable String contentType, byte @Nullable[] header)
{
if ((path == null) || (_dir != null && _dir.booleanValue() != Files.isDirectory(path)))
return false;

return isType(path.getFileName().toString(), contentType, header);
// A root has no file name; use "" to match File.getName()
Path fileName = path.getFileName();
return isType(fileName == null ? "" : fileName.toString(), contentType, header);
}


public boolean isType(File file, String contentType, byte[] header)
public boolean isType(@Nullable File file, @Nullable String contentType, byte @Nullable[] header)
{
if ((file == null) || (_dir != null && _dir.booleanValue() != file.isDirectory()))
return false;
Expand All @@ -525,7 +526,7 @@ public boolean isType(File file, String contentType, byte[] header)
/**
* Checks if the path matches any of the suffixes
*/
public boolean isType(String filePath)
public boolean isType(@Nullable String filePath)
{
return isType(filePath, null, null);
}
Expand Down
Loading