Exemplo n.º 1
0
        private static void AddDataFilesFromFolder(DirectoryInfo folder, StringBuilder itemPath,
                                                   IList <DataFile> dataFiles)
        {
            FileInfo[]      files   = folder.GetFiles();
            DirectoryInfo[] folders = folder.GetDirectories();
            if ((files == null || files.Length == 0) && (folders == null || folders.Length == 0))
            {
                return;
            }
            int folderPathLength = itemPath.Length;

            if (folderPathLength > 0)
            {
                // The item path must use the ICU file separator character,
                // not the platform-dependent File.separatorChar,
                // so that the enumerated item paths match the paths requested by ICU code.
                itemPath.Append('/');
                ++folderPathLength;
            }
            foreach (DirectoryInfo folder2 in folders)
            {
                // TODO: Within a folder, put all single files before all .dat packages?
                AddDataFilesFromFolder(folder2, itemPath, dataFiles);
            }

            foreach (FileInfo file in files)
            {
                string fileName = file.Name;
                if (fileName.EndsWith(".txt", StringComparison.Ordinal))
                {
                    continue;
                }
                itemPath.Append(fileName);
                if (fileName.EndsWith(".dat", StringComparison.Ordinal))
                {
                    ByteBuffer pkgBytes = MapFile(file);
                    if (pkgBytes != null && DatPackageReader.Validate(pkgBytes))
                    {
                        dataFiles.Add(new PackageDataFile(itemPath.ToString(), pkgBytes));
                    }
                }
                else
                {
                    dataFiles.Add(new SingleDataFile(itemPath.ToString(), file));
                }
                itemPath.Length = folderPathLength;
            }
        }
Exemplo n.º 2
0
 internal override void AddBaseNamesInFolder(string folder, string suffix, ISet <string> names)
 {
     DatPackageReader.AddBaseNamesInFolder(pkgBytes, folder, suffix, names);
 }
Exemplo n.º 3
0
 internal override ByteBuffer GetData(string requestedPath)
 {
     return(DatPackageReader.GetData(pkgBytes, requestedPath));
 }