public static void AddTree(DirNode dirNode, string dirPrefix, string filePrefix, int width, int depth, int fileSizeInKB, FileAttributes?fa = null, DateTime?lmt = null) { for (int i = 0; i < width; ++i) { string fileName = i == 0 ? filePrefix : filePrefix + "_" + i; FileNode fileNode = new FileNode(fileName) { SizeInByte = 1024L * fileSizeInKB, FileAttr = fa, LastModifiedTime = lmt, }; dirNode.AddFileNode(fileNode); } if (depth > 0) { for (int i = 0; i < width; ++i) { string dirName = i == 0 ? dirPrefix : dirPrefix + "_" + i; DirNode subDirNode = dirNode.GetDirNode(dirName); if (subDirNode == null) { subDirNode = new DirNode(dirName); dirNode.AddDirNode(subDirNode); } DMLibDataHelper.AddTree(subDirNode, dirPrefix, filePrefix, width, depth - 1, fileSizeInKB, fa, lmt: lmt); } } }
public static void AddMultipleFiles( DirNode dirNode, string filePrefix, int fileNumber, int fileSizeInKB, FileAttributes?fa = null, DateTime?lmt = null, string cacheControl = null, string contentDisposition = null, string contentEncoding = null, string contentLanguage = null, string contentType = null, string md5 = null, IDictionary <string, string> metadata = null) { DMLibDataHelper.AddTree( dirNode, string.Empty, filePrefix, fileNumber, 0, fileSizeInKB, fa, lmt, cacheControl, contentDisposition, contentEncoding, contentLanguage, contentType, md5, metadata); }
public static void AddTreeTotalSize(DirNode dirNode, string dirPrefix, string filePrefix, int width, int depth, int totalSizeInKB, DateTime?lmt = null) { int fileNumber; if (width <= 1) { fileNumber = (depth + 1) * width; } else { int widthPowDepth = width; for (int i = 0; i < depth; ++i) { widthPowDepth *= width; } fileNumber = width * (widthPowDepth - 1) / (width - 1); } int fileSizeInKB = totalSizeInKB / fileNumber; fileSizeInKB = fileSizeInKB == 0 ? 1 : fileSizeInKB; DMLibDataHelper.AddTree(dirNode, dirPrefix, filePrefix, width, depth, fileSizeInKB, lmt: lmt); }
public static void AddTree( DirNode dirNode, string dirPrefix, string filePrefix, int width, int depth, int fileSizeInKB, FileAttributes?fa = null, DateTime?lmt = null, string cacheControl = null, string contentDisposition = null, string contentEncoding = null, string contentLanguage = null, string contentType = null, string md5 = null, IDictionary <string, string> metadata = null) { for (int i = 0; i < width; ++i) { string fileName = i == 0 ? filePrefix : filePrefix + "_" + i; FileNode fileNode = new FileNode(fileName) { SizeInByte = 1024L * fileSizeInKB, FileAttr = fa, LastModifiedTime = lmt, CacheControl = cacheControl, ContentDisposition = contentDisposition, ContentEncoding = contentEncoding, ContentLanguage = contentLanguage, ContentType = contentType, MD5 = md5, Metadata = metadata }; dirNode.AddFileNode(fileNode); } if (depth > 0) { for (int i = 0; i < width; ++i) { string dirName = i == 0 ? dirPrefix : dirPrefix + "_" + i; DirNode subDirNode = dirNode.GetDirNode(dirName); if (subDirNode == null) { subDirNode = new DirNode(dirName); dirNode.AddDirNode(subDirNode); } DMLibDataHelper.AddTree(subDirNode, dirPrefix, filePrefix, width, depth - 1, fileSizeInKB, fa, lmt: lmt); } } }
public static void AddMultipleFiles(DirNode dirNode, string filePrefix, int fileNumber, int fileSizeInKB, FileAttributes?fa = null, DateTime?lmt = null) { DMLibDataHelper.AddTree(dirNode, string.Empty, filePrefix, fileNumber, 0, fileSizeInKB, fa, lmt); }