/// <summary> /// 通过给定文件夹下的文件 /// </summary> /// <param name="path">文件夹路径</param> /// <param name="searchOption">搜索方式</param> /// <returns>文件集合</returns> public List <IStorageFile> GetFiles(string path, PathSearchOption searchOption) { List <IStorageFile> files = new List <IStorageFile>(); string localPath = GetFullLocalPath(path, string.Empty); string parentPath = localPath.Substring(0, localPath.LastIndexOf(Path.DirectorySeparatorChar)); if (Directory.Exists(localPath)) { foreach (FileInfo file in (new DirectoryInfo(localPath)).GetFiles("*.*", searchOption == PathSearchOption.AllPaths ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly)) { if (file.Name != PlaceHolderFileName && (file.Attributes & FileAttributes.Hidden) != FileAttributes.Hidden) { FileSystemStorageFile fsFile = new FileSystemStorageFile(this._fileStoreKey, GetPath(file.FullName), file); files.Add(fsFile); } } } else if (Directory.Exists(parentPath)) { foreach (FileInfo file in (new DirectoryInfo(parentPath)).GetFiles("*.*", SearchOption.AllDirectories)) { if ((file.Attributes & FileAttributes.Hidden) != FileAttributes.Hidden && GetPath(file.FullName).StartsWith(path)) { FileSystemStorageFile fsFile = new FileSystemStorageFile(this._fileStoreKey, GetPath(file.FullName), file); files.Add(fsFile); } } } return(files); }
public IEnumerable <ICentralizedFile> GetFiles(string path, PathSearchOption searchOption) { using (new TracePoint($"[cfs] GetFiles '{FileStoreKey}' '{path}'")) { return(ListChildren(path, searchOption) .OfType <CloudBlockBlob>() .Select(x => new AzureBlobFileReference(x, _fileStoreData))); } }
public IEnumerable <ICentralizedFile> GetFiles(string path, PathSearchOption searchOption) { using (new TracePoint($"[cfs] GetFiles '{FileStoreKey}' '{path}'")) { return(ListChildren(path, searchOption) .OfType <CloudBlockBlob>() .Select(ConvertBlobToCentralizedFile)); } }
private IEnumerable<ICentralizedFile> GetFiles(PathSearchOption searchOption, bool includePlaceHolders) { List<ICentralizedFile> centralizedFileList = new List<ICentralizedFile>(); foreach (AmazonS3FileStorageFile file in QueryPath(string.Empty, searchOption).Files) { if (includePlaceHolders || file.FileName != AmazonS3FileStorageProvider.PLACE_HOLDER_FILENAME) centralizedFileList.Add((ICentralizedFile)file); } return centralizedFileList; }
private IEnumerable<ICentralizedFile> GetFiles(string path, PathSearchOption searchOption, bool includePlaceHolders) { if (!CentralizedFileStorage.IsValidPath(path)) throw new ApplicationException("The provided path is invalid"); List<ICentralizedFile> centralizedFileList = new List<ICentralizedFile>(); foreach (AmazonS3FileStorageFile file in QueryPath(path, searchOption).Files) { if (includePlaceHolders || file.FileName != AmazonS3FileStorageProvider.PLACE_HOLDER_FILENAME) centralizedFileList.Add((ICentralizedFile)file); } return centralizedFileList; }
protected void ListDataBind() { if (fileStore == null) { //plugin is not enabled, bail out return; } list.Items.Clear(); PathSearchOption search = new PathSearchOption(); IEnumerable<ICentralizedFile> mune = fileStore.GetFiles(search); foreach (ICentralizedFile file in mune) { list.Items.Add(new ListItem(file.FileName)); } }
/// <summary> /// 文件系统下的文件 /// </summary> /// <param name="searchOption"><搜索方式/param> /// <returns>文件集合</returns> public List <IStorageFile> GetFiles(PathSearchOption searchOption) { List <IStorageFile> files = new List <IStorageFile>(); foreach (FileInfo file in (new DirectoryInfo(GetBaseFolder())). GetFiles("*.*", searchOption == PathSearchOption.AllPaths ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly)) { if (file.Name != PlaceHolderFileName && (file.Attributes & FileAttributes.Hidden) != FileAttributes.Hidden) { FileSystemStorageFile fsFile = new FileSystemStorageFile(this.FileStoreKey, GetPath(file.FullName), file); files.Add(fsFile); } } return(files); }
protected void ListDataBind() { if (fileStore == null) { //plugin is not enabled, bail out return; } list.Items.Clear(); PathSearchOption search = new PathSearchOption(); IEnumerable <ICentralizedFile> mune = fileStore.GetFiles(search); foreach (ICentralizedFile file in mune) { list.Items.Add(new ListItem(file.FileName)); } }
private IEnumerable <IListBlobItem> ListChildren(string path, PathSearchOption searchOption) { bool includeSubDirectories = searchOption == PathSearchOption.AllPaths; IEnumerable <IListBlobItem> blobs; if (string.IsNullOrEmpty(path)) { blobs = _container.ListBlobs(useFlatBlobListing: includeSubDirectories); } else { var azurePath = ConvertCfsPathToAzurePath(path); blobs = _container.GetDirectoryReference(azurePath) .ListBlobs(includeSubDirectories); } return(new NotFoundHandlingEnumerable(blobs)); }
private AmazonS3PathQueryResults QueryPath(string path, PathSearchOption searchOption) { var results = this.GetAmazonS3PathQueryResultsFromCache(path, searchOption); if (results == null) { lock (_lockbox.GetObject(this.CreateAmazonS3PathQueryResultsPrimaryKey(path, searchOption).GetHashCode())) { results = this.GetAmazonS3PathQueryResultsFromCache(path, searchOption); if (results == null) { var files = new List<AmazonS3FileStorageFile>(); var subPaths = new List<string>(); ObjectListResponse response = searchOption != PathSearchOption.AllPaths ? this.GetConnection().ListBucket(this._bucketName, this.MakeKey(path, string.Empty), "", int.MaxValue, "/", new SortedList<string, string>()) : this.GetConnection().ListBucket(this._bucketName, this.MakeKey(path, string.Empty), "", int.MaxValue, new SortedList<string, string>()); foreach (var commonPrefixEntry in response.CommonPrefixEntries) subPaths.Add(this.GetPath(commonPrefixEntry.Prefix, false)); foreach (var entry in response.Entries) { string filePath = GetPath(entry.Key); string fileName = GetFileName(entry.Key); AmazonS3FileStorageFile file = this.GetAmazonS3FileStorageFileFromCache(filePath, fileName); if (file == null) { lock (_lockbox.GetObject(this.CreateAmazonS3FileStorageFilePrimaryKey(filePath, fileName).GetHashCode())) { file = this.GetAmazonS3FileStorageFileFromCache(filePath, fileName); if (file == null) { file = new AmazonS3FileStorageFile(this.FileStoreKey, filePath, fileName, (int)entry.ContentLength); this.PushAmazonS3FileStorageFileToCache(file, filePath, fileName); } } } files.Add(file); } results = new AmazonS3PathQueryResults(subPaths, files); this.PushAmazonS3PathQueryResultsToCache(results, path, searchOption); } } } return results; }
private void PushAmazonS3PathQueryResultsToCache(AmazonS3PathQueryResults results, string path, PathSearchOption searchOption) { var key = this.CreateAmazonS3PathQueryResultsPrimaryKey(path, searchOption); Evolution.Extensibility.Caching.Version1.CacheService.Put(key, results, CacheScope.Context | CacheScope.Process); }
private void PushAmazonS3PathQueryResultsToCache(AmazonS3FileStorageProvider.AmazonS3PathQueryResults results, string path, PathSearchOption searchOption) { CacheService.Put(this.CreateAmazonS3PathQueryResultsPrimaryKey(path, searchOption), (object)results, CacheScope.Context | CacheScope.Process); }
public IEnumerable <ICentralizedFile> GetFiles(PathSearchOption searchOption) => GetFiles(string.Empty, searchOption);
private AmazonS3FileStorageProvider.AmazonS3PathQueryResults GetAmazonS3PathQueryResultsFromCache(string path, PathSearchOption searchOption) { return (AmazonS3FileStorageProvider.AmazonS3PathQueryResults)CacheService.Get(this.CreateAmazonS3PathQueryResultsPrimaryKey(path, searchOption), CacheScope.Context | CacheScope.Process); }
public IEnumerable <ICentralizedFile> GetFiles(string path, PathSearchOption searchOption) { return(GetFiles(path, searchOption, false)); }
private string CreateAmazonS3PathQueryResultsPrimaryKey(string path, PathSearchOption searchOption) { return(string.Format("PK_AMAZON-S3-QUERY-RESULTS:{0},{1},{2}", _bucketName, searchOption.ToString(), this.MakeKey(path, string.Empty))); }
private AmazonS3PathQueryResults GetAmazonS3PathQueryResultsFromCache(string path, PathSearchOption searchOption) { var key = this.CreateAmazonS3PathQueryResultsPrimaryKey(path, searchOption); return((AmazonS3PathQueryResults)Evolution.Extensibility.Caching.Version1.CacheService.Get(key, CacheScope.Context | CacheScope.Process)); }
public IEnumerable<ICentralizedFile> GetFiles(PathSearchOption searchOption) { return GetFiles(searchOption, false); }