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


Java FileUtils.getCanonical方法代码示例

本文整理汇总了Java中io.vov.vitamio.utils.FileUtils.getCanonical方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtils.getCanonical方法的具体用法?Java FileUtils.getCanonical怎么用?Java FileUtils.getCanonical使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.vov.vitamio.utils.FileUtils的用法示例。


在下文中一共展示了FileUtils.getCanonical方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: prescan

import io.vov.vitamio.utils.FileUtils; //导入方法依赖的package包/类
private void prescan(String filePath) throws RemoteException {
  mProvider = mContext.getContentResolver().acquireContentProviderClient(MediaStore.AUTHORITY);
  Cursor c = null;
  String where = null;
  String[] selectionArgs = null;

  if (mFileCache == null)
    mFileCache = new HashMap<String, FileCacheEntry>();
  else
    mFileCache.clear();

  try {
    if (filePath != null) {
      where = Video.Media.DATA + "=?";
      selectionArgs = new String[]{filePath};
    }

    c = mProvider.query(Video.Media.CONTENT_URI, VIDEO_PROJECTION, where, selectionArgs, null);
    if (c != null) {
      try {
        while (c.moveToNext()) {
          long rowId = c.getLong(ID_VIDEO_COLUMN_INDEX);
          String path = c.getString(PATH_VIDEO_COLUMN_INDEX);
          long lastModified = c.getLong(DATE_MODIFIED_VIDEO_COLUMN_INDEX);
          if (path.startsWith("/")) {
            File tempFile = new File(path);
            if (!TextUtils.isEmpty(filePath) && !tempFile.exists()) {
              mProvider.delete(Video.Media.CONTENT_URI, where, selectionArgs);
              return;
            }
            path = FileUtils.getCanonical(tempFile);
            String key = mCaseInsensitivePaths ? path.toLowerCase() : path;
            mFileCache.put(key, new FileCacheEntry(Video.Media.CONTENT_URI, rowId, path, lastModified));
          }
        }
      } finally {
        c.close();
        c = null;
      }
    }
  } finally {
    if (c != null) {
      c.close();
    }
  }
}
 
开发者ID:coding-dream,项目名称:TPlayer,代码行数:47,代码来源:MediaScanner.java

示例2: prescan

import io.vov.vitamio.utils.FileUtils; //导入方法依赖的package包/类
private void prescan(String filePath) throws RemoteException {
    mProvider = mContext.getContentResolver().acquireContentProviderClient(MediaStore.AUTHORITY);
    Cursor c = null;
    String where = null;
    String[] selectionArgs = null;

    if (mFileCache == null)
        mFileCache = new HashMap<String, FileCacheEntry>();
    else
        mFileCache.clear();

    try {
        if (filePath != null) {
            where = Video.Media.DATA + "=?";
            selectionArgs = new String[]{filePath};
        }

        c = mProvider.query(Video.Media.CONTENT_URI, VIDEO_PROJECTION, where, selectionArgs, null);
        if (c != null) {
            try {
                while (c.moveToNext()) {
                    long rowId = c.getLong(ID_VIDEO_COLUMN_INDEX);
                    String path = c.getString(PATH_VIDEO_COLUMN_INDEX);
                    long lastModified = c.getLong(DATE_MODIFIED_VIDEO_COLUMN_INDEX);
                    if (path.startsWith("/")) {
                        File tempFile = new File(path);
                        if (!TextUtils.isEmpty(filePath) && !tempFile.exists()) {
                            mProvider.delete(Video.Media.CONTENT_URI, where, selectionArgs);
                            return;
                        }
                        path = FileUtils.getCanonical(tempFile);
                        String key = mCaseInsensitivePaths ? path.toLowerCase() : path;
                        mFileCache.put(key, new FileCacheEntry(Video.Media.CONTENT_URI, rowId, path, lastModified));
                    }
                }
            } finally {
                c.close();
                c = null;
            }
        }
    } finally {
        if (c != null) {
            c.close();
        }
    }
}
 
开发者ID:WangZhiYao,项目名称:VideoDemo,代码行数:47,代码来源:MediaScanner.java


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