ContainsEntry() public method

public ContainsEntry ( string key, string filename ) : bool
key string
filename string
return bool
Ejemplo n.º 1
0
        protected CacheManifest GetCachedManifestLocked(DataHash commonkey)
        {
            CacheManifest manifest = null;

            if (outputCache.ContainsEntry(commonkey.Hash, F_Manifest))
            {
                var mn = outputCache.MakePath(commonkey.Hash, F_Manifest);
                using (var fs = new FileStream(mn, FileMode.Open)){
                    manifest = CacheManifest.Deserialize(fs);
                }
            }

            return(manifest);
        }
Ejemplo n.º 2
0
        DataHash DigestFile(MD5 provider, string filepath, Regex findDateTime)
        {
            var rv = new DataHash()
            {
                Result    = DataHashResult.FileNotFound,
                InputName = filepath,
            };

            if (!FileUtils.Exists(filepath))
            {
                return(rv);
            }
            provider.Initialize();
            var fs = new FileStream(filepath, FileMode.Open, FileAccess.Read, FileShare.Read);

            using (var bs = new BufferedStream(fs))
            {
                Logging.Emit("digest {0}", filepath);
                rv.Hash   = new SoapHexBinary(provider.ComputeHash(bs)).ToString();
                rv.Result = DataHashResult.Ok;

                if (findDateTime != null)
                {
                    // check include cache for this file

                    if (includeCache.ContainsEntry(rv.Hash, F_NotDateTime))
                    {
                        return(rv);
                    }
                    if (includeCache.ContainsEntry(rv.Hash, F_HasDateTime))
                    {
                        rv.Result = DataHashResult.ContainsTimeOrDate;
                        return(rv);
                    }

                    bs.Seek(0, SeekOrigin.Begin);
                    using (var ts = new StreamReader(bs))
                    {
                        string line = null;
                        do
                        {
                            line = ts.ReadLine();
                            if (line == null)
                            {
                                includeCache.WaitOne();
                                try
                                {
                                    includeCache.AddTextFileContent(rv.Hash, F_NotDateTime, "");
                                }
                                finally
                                {
                                    includeCache.ReleaseMutex();
                                }
                                break;
                            }

                            if (findDateTime.IsMatch(line))
                            {
                                rv.Result = DataHashResult.ContainsTimeOrDate;

                                includeCache.WaitOne();
                                try
                                {
                                    includeCache.AddTextFileContent(rv.Hash, F_HasDateTime, "");
                                }
                                finally
                                {
                                    includeCache.ReleaseMutex();
                                }

                                break;
                            }
                        } while (true);
                    }
                }
            }
            rv.Result = DataHashResult.Ok;

            return(rv);
        }