示例#1
0
        public static string ProcessLoadedSound(List <string> columns)
        {
            if (columns.Count > 1)
            {
                return(CODTraps.ReplacePathSeps(columns[1]));
            }

            return(null);
        }
示例#2
0
        int AddFilesToZIP(ZipFile zip, string folderInArchive, List <string> searchDirs, List <string> fileFullPaths)
        {
            int count = 0;

            // delete old unused files..
            Trace.TraceEvent(TraceEventType.Verbose, 0, "Removing old files from IWD...");
            List <string> entriesToRemove = new List <string>();

            foreach (ZipEntry entry in zip.Entries)
            {
                if (!CODTraps.ReplacePathSeps(entry.FileName).StartsWith(folderInArchive))
                {
                    continue;
                }

                string shortPath = CODTraps.ReplacePathSeps(entry.FileName).Substring(folderInArchive.Length + 1);
                if (!AssetListContainsShortPath(shortPath, searchDirs, fileFullPaths))
                {
                    entriesToRemove.Add(entry.FileName);
                    Trace.TraceEvent(TraceEventType.Verbose, 0, CODTraps.ReplacePathSeps(entry.FileName));
                    count++;
                }
            }
            zip.RemoveEntries(entriesToRemove);

            // add & modify files...
            Trace.TraceEvent(TraceEventType.Verbose, 0, "Updating files in IWD...");
            foreach (string fileFullPath in fileFullPaths)
            {
                string shortPath     = GetShortPath(fileFullPath, searchDirs);
                string pathInArchive = Path.Combine(folderInArchive, shortPath);

                ZipEntry entry = zip.Entries.FirstOrDefault(a => CODTraps.ReplacePathSeps(a.FileName) == pathInArchive);
                if (entry == null)
                {
                    entry = zip.AddFile(fileFullPath, Path.Combine(folderInArchive, Path.GetDirectoryName(shortPath)));
                    entry.LastModified     = DateTime.Now;
                    entry.CompressionLevel = _compression;
                    Trace.TraceEvent(TraceEventType.Verbose, 0, CODTraps.ReplacePathSeps(entry.FileName));
                    count++;
                }
                else if (!_compareDate || File.GetLastWriteTime(fileFullPath) > entry.LastModified)
                {
                    entry = zip.UpdateFile(fileFullPath, Path.Combine(folderInArchive, Path.GetDirectoryName(shortPath)));
                    entry.LastModified     = DateTime.Now;
                    entry.CompressionLevel = _compression;
                    Trace.TraceEvent(TraceEventType.Verbose, 0, CODTraps.ReplacePathSeps(entry.FileName));
                    count++;
                }
            }

            return(count);
        }
示例#3
0
        public List <string> GetSoundFileList()
        {
            List <string> files = new List <string>();

            int nameColumnI = -1;
            int fileColumnI = -1;

            foreach (List <string> lineColumns in GetItems())
            {
                if (lineColumns.Count > 0)
                {
                    if (nameColumnI == -1)
                    {
                        for (int i = 0; i < lineColumns.Count; i++)
                        {
                            if (lineColumns[i] == "name")
                            {
                                nameColumnI = i;
                            }
                            else if (lineColumns[i] == "file")
                            {
                                fileColumnI = i;
                            }
                        }
                        if (nameColumnI == -1 || fileColumnI == -1)
                        {
                            throw new ApplicationException("Could not read column-specify line in soundalias '" + FileName + "'");
                        }
                    }
                    else
                    {
                        files.Add(CODTraps.ReplacePathSeps(lineColumns[fileColumnI]));
                    }
                }
            }

            return(files);
        }