当前位置: 首页>>代码示例>>Java>>正文


Java StructStat类代码示例

本文整理汇总了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;
}
 
开发者ID:google,项目名称:samba-documents-provider,代码行数:18,代码来源:LoadStatTask.java

示例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;
}
 
开发者ID:google,项目名称:samba-documents-provider,代码行数:17,代码来源:DocumentMetadata.java

示例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;
}
 
开发者ID:IvanVolosyuk,项目名称:diskusage,代码行数:31,代码来源:Scanner.java

示例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();
    }
}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:11,代码来源:CleanCacheService21.java

示例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();
  }
}
 
开发者ID:google,项目名称:samba-documents-provider,代码行数:9,代码来源:SambaFacadeClient.java

示例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);
  }
}
 
开发者ID:google,项目名称:samba-documents-provider,代码行数:9,代码来源:SambaFile.java

示例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);
  }
}
 
开发者ID:google,项目名称:samba-documents-provider,代码行数:10,代码来源:NativeSambaFacade.java

示例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();
  }
}
 
开发者ID:google,项目名称:samba-documents-provider,代码行数:9,代码来源:SambaFileClient.java

示例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;
}
 
开发者ID:google,项目名称:samba-documents-provider,代码行数:13,代码来源:SambaProxyFileCallback.java

示例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());
    }
}
 
开发者ID:cketti,项目名称:SafeContentResolver,代码行数:10,代码来源:SafeContentResolverApi21.java

示例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;
  }
 
开发者ID:IvanVolosyuk,项目名称:diskusage,代码行数:36,代码来源:Scanner.java

示例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);
}
 
开发者ID:FlightOfStairs,项目名称:ADirStat,代码行数:10,代码来源:Scanner.java

示例13: onPostExecute

import android.system.StructStat; //导入依赖的package包/类
@Override
public void onPostExecute(Map<Uri, StructStat> stats) {
  mCallback.onTaskFinished(OnTaskFinishedCallback.SUCCEEDED, mMetadataMap, null);
}
 
开发者ID:google,项目名称:samba-documents-provider,代码行数:5,代码来源:LoadStatTask.java

示例14: onCancelled

import android.system.StructStat; //导入依赖的package包/类
@Override
public void onCancelled(Map<Uri, StructStat> stats) {
  mCallback.onTaskFinished(OnTaskFinishedCallback.CANCELLED, mMetadataMap, null);
}
 
开发者ID:google,项目名称:samba-documents-provider,代码行数:5,代码来源:LoadStatTask.java

示例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);
}
 
开发者ID:google,项目名称:samba-documents-provider,代码行数:5,代码来源:DocumentMetadata.java


注:本文中的android.system.StructStat类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。