コード例 #1
0
ファイル: IMGArchive.cs プロジェクト: BigETI/IMGSharp
        /// <summary>
        /// Create IMG archive entry
        /// </summary>
        /// <param name="entryName">Entry name</param>
        /// <returns>IMG archive entry if successful, otherwise "null"</returns>
        public IIMGArchiveEntry CreateEntry(string entryName)
        {
            if (entryName == null)
            {
                throw new ArgumentNullException(nameof(entryName));
            }
            IIMGArchiveEntry ret        = null;
            string           entry_name = entryName.Trim();
            bool             proceed    = true;

            Parallel.ForEach(Path.GetInvalidPathChars(), (invalid_path_character, parallelLoopState) =>
            {
                if (entry_name.Contains(invalid_path_character.ToString()))
                {
                    proceed = false;
                    parallelLoopState.Break();
                }
            });
            if (proceed)
            {
                string key = entry_name.ToLower();
                if (!InternalEntries.ContainsKey(key))
                {
                    InternalEntries.Add(key, new IMGArchiveEntry(this, Stream.Length, 0, entry_name, true));
                }
            }
            return(ret);
        }
コード例 #2
0
ファイル: IMGArchive.cs プロジェクト: BigETI/IMGSharp
        /// <summary>
        /// Get IMG archive entry
        /// </summary>
        /// <param name="entryName">Entry name</param>
        /// <returns>IMG archive entry if successful, otherwise "null"</returns>
        public IIMGArchiveEntry GetEntry(string entryName)
        {
            if (entryName == null)
            {
                throw new ArgumentNullException(nameof(entryName));
            }
            string key = entryName.ToLower();

            return(InternalEntries.ContainsKey(key) ? InternalEntries[key] : null);
        }