NaTo1000's picture
download
raw
2.14 kB
package com.termux.shared.file.filesystem;
import android.system.ErrnoException;
import android.system.Os;
import java.io.File;
import java.io.FileDescriptor;
import java.io.IOException;
public class NativeDispatcher {
public static void stat(String filePath, FileAttributes fileAttributes) throws IOException {
validateFileExistence(filePath);
try {
fileAttributes.loadFromStructStat(Os.stat(filePath));
} catch (ErrnoException e) {
throw new IOException("Failed to run Os.stat() on file at path \"" + filePath + "\": " + e.getMessage());
}
}
public static void lstat(String filePath, FileAttributes fileAttributes) throws IOException {
validateFileExistence(filePath);
try {
fileAttributes.loadFromStructStat(Os.lstat(filePath));
} catch (ErrnoException e) {
throw new IOException("Failed to run Os.lstat() on file at path \"" + filePath + "\": " + e.getMessage());
}
}
public static void fstat(FileDescriptor fileDescriptor, FileAttributes fileAttributes) throws IOException {
validateFileDescriptor(fileDescriptor);
try {
fileAttributes.loadFromStructStat(Os.fstat(fileDescriptor));
} catch (ErrnoException e) {
throw new IOException("Failed to run Os.fstat() on file descriptor \"" + fileDescriptor.toString() + "\": " + e.getMessage());
}
}
public static void validateFileExistence(String filePath) throws IOException {
if (filePath == null || filePath.isEmpty()) throw new IOException("The path is null or empty");
File file = new File(filePath);
//if (!file.exists())
// throw new IOException("No such file or directory: \"" + filePath + "\"");
}
public static void validateFileDescriptor(FileDescriptor fileDescriptor) throws IOException {
if (fileDescriptor == null) throw new IOException("The file descriptor is null");
if (!fileDescriptor.valid())
throw new IOException("No such file descriptor: \"" + fileDescriptor.toString() + "\"");
}
}

Xet Storage Details

Size:
2.14 kB
·
Xet hash:
a5786799f6ee18fa761d331e08a7c25498017ba80e6f670906486f4c7ee52f15

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.