本文整理汇总了Java中android.system.StructStat类的典型用法代码示例。如果您正苦于以下问题:Java StructStat类的具体用法?Java StructStat怎么用?Java StructStat使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StructStat类属于android.system包,在下文中一共展示了StructStat类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doInBackground
import android.system.StructStat; //导入依赖的package包/类
@Override
public Map<Uri, StructStat> doInBackground(Void... args) {
Map<Uri, StructStat> stats = new HashMap<>(mMetadataMap.size());
for (DocumentMetadata metadata : mMetadataMap.values()) {
try {
metadata.loadStat(mClient);
if (isCancelled()) {
return stats;
}
} catch(Exception e) {
// Failed to load a stat for a child... Just eat this exception, the only consequence it may
// have is constantly retrying to fetch the stat.
Log.e(TAG, "Failed to load stat for " + metadata.getUri());
}
}
return stats;
}
示例2: fromUri
import android.system.StructStat; //导入依赖的package包/类
public static DocumentMetadata fromUri(Uri uri, SmbClient client) throws IOException {
final List<String> pathSegments = uri.getPathSegments();
if (pathSegments.isEmpty()) {
throw new UnsupportedOperationException("Can't load metadata for workgroup or server.");
}
final StructStat stat = client.stat(uri.toString());
final DirectoryEntry entry = new DirectoryEntry(
OsConstants.S_ISDIR(stat.st_mode) ? DirectoryEntry.DIR : DirectoryEntry.FILE,
"",
uri.getLastPathSegment());
final DocumentMetadata metadata = new DocumentMetadata(uri, entry);
metadata.mStat.set(stat);
return metadata;
}
示例3: calculateSize
import android.system.StructStat; //导入依赖的package包/类
/**
* Calculate size of the entry reading directory tree
* @param file is file corresponding to this entry
* @return size of entry in blocks
*/
private final long calculateSize(LegacyFile file) {
if (file.isLink()) return 0;
if (file.isFile()) {
try {
StructStat res = Os.stat(file.getCannonicalPath());
return res.st_blocks;
} catch (ErrnoException|IOException e) {
return 0;
}
}
LegacyFile[] list = null;
try {
list = file.listFiles();
} catch (SecurityException io) {
Log.e("diskusage", "list files", io);
}
if (list == null) return 0;
long size = 1;
for (int i = 0; i < list.length; i++)
size += calculateSize(list[i]);
return size;
}
示例4: deleteIfOld
import android.system.StructStat; //导入依赖的package包/类
static void deleteIfOld(File file, long olderThan) {
try {
StructStat stat = Os.lstat(file.getAbsolutePath());
if ((stat.st_atime * 1000L) < olderThan) {
file.delete();
}
} catch (ErrnoException e) {
e.printStackTrace();
}
}
示例5: stat
import android.system.StructStat; //导入依赖的package包/类
@Override
public StructStat stat(String uri) throws IOException {
try (final MessageValues<StructStat> messageValues = MessageValues.obtain()) {
final Message msg = obtainMessage(STAT, messageValues, uri);
enqueue(msg);
return messageValues.getObj();
}
}
示例6: fstat
import android.system.StructStat; //导入依赖的package包/类
@Override
public StructStat fstat() throws IOException {
try {
return fstat(mNativeHandler, mNativeFd);
} catch (ErrnoException e) {
throw new IOException("Failed to get stat of " + mNativeFd, e);
}
}
示例7: stat
import android.system.StructStat; //导入依赖的package包/类
@Override
public StructStat stat(String uri) throws IOException {
try {
checkNativeHandler();
return stat(mNativeHandler, uri);
} catch (ErrnoException e) {
throw new IOException("Failed to get stat of " + uri, e);
}
}
示例8: fstat
import android.system.StructStat; //导入依赖的package包/类
@Override
public StructStat fstat() throws IOException {
try (final MessageValues<StructStat> messageValues = MessageValues.obtain()) {
final Message msg = mHandler.obtainMessage(FSTAT, messageValues);
enqueue(msg);
return messageValues.getObj();
}
}
示例9: onGetSize
import android.system.StructStat; //导入依赖的package包/类
@Override
public long onGetSize() throws ErrnoException {
StructStat stat;
try {
stat = mFile.fstat();
return stat.st_size;
} catch (IOException e) {
throwErrnoException(e);
}
return 0;
}
示例10: getFileUidOrThrow
import android.system.StructStat; //导入依赖的package包/类
@Override
protected int getFileUidOrThrow(@NonNull FileDescriptor fileDescriptor) throws FileNotFoundException {
try {
StructStat st = Os.fstat(fileDescriptor);
return st.st_uid;
} catch (android.system.ErrnoException e) {
throw new FileNotFoundException(e.getMessage());
}
}
示例11: scan
import android.system.StructStat; //导入依赖的package包/类
public FileSystemEntry scan(LegacyFile file) throws IOException {
long st_blocks;
try {
StructStat stat = Os.stat(file.getCannonicalPath());
dev = stat.st_dev;
st_blocks = stat.st_blocks;
} catch (ErrnoException e) {
throw new IOException("Failed to find root folder", e);
}
scanDirectory(null, file, 0, st_blocks / blockSizeIn512Bytes);
int extraHeap = 0;
// Restoring blocks
for (SmallList list : smallLists) {
// print("restored", list);
FileSystemEntry[] oldChildren = list.parent.children;
FileSystemEntry[] addChildren = list.children;
FileSystemEntry[] newChildren =
new FileSystemEntry[oldChildren.length - 1 + addChildren.length];
System.arraycopy(addChildren, 0, newChildren, 0, addChildren.length);
for(int pos = addChildren.length, i = 0; i < oldChildren.length; i++) {
FileSystemEntry c = oldChildren[i];
if (! (c instanceof FileSystemEntrySmall)) {
newChildren[pos++] = c;
}
}
java.util.Arrays.sort(newChildren, FileSystemEntry.COMPARE);
list.parent.children = newChildren;
extraHeap += list.heapSize;
}
Log.d("diskusage", "allocated " + extraHeap + " B of extra heap");
Log.d("diskusage", "allocated " + (extraHeap + createdNodeSize) + " B total");
return createdNode;
}
示例12: smartLength
import android.system.StructStat; //导入依赖的package包/类
@TargetApi(LOLLIPOP)
@SneakyThrows
private static long smartLength(File file) {
long length = file.length();
StructStat stat = Os.stat(file.getAbsolutePath());
long blockBasedLength = stat.st_blksize * stat.st_blocks;
return min(length, blockBasedLength);
}
示例13: onPostExecute
import android.system.StructStat; //导入依赖的package包/类
@Override
public void onPostExecute(Map<Uri, StructStat> stats) {
mCallback.onTaskFinished(OnTaskFinishedCallback.SUCCEEDED, mMetadataMap, null);
}
示例14: onCancelled
import android.system.StructStat; //导入依赖的package包/类
@Override
public void onCancelled(Map<Uri, StructStat> stats) {
mCallback.onTaskFinished(OnTaskFinishedCallback.CANCELLED, mMetadataMap, null);
}
示例15: getLastModified
import android.system.StructStat; //导入依赖的package包/类
public Long getLastModified() {
final StructStat stat = mStat.get();
return (stat == null) ? null : TimeUnit.MILLISECONDS.convert(stat.st_mtime, TimeUnit.SECONDS);
}