Beispiel #1
0
        private unsafe void UpdateState(string directory, ref FileChangeList changes, ref WIN32_FIND_DATAW file, char *filename)
        {
            int index = _state.IndexOf(directory, filename);

            if (index == -1) // file added
            {
                string path = new string(filename);

                if (file.IsDirectory)
                {
                    if (_includeSubdirectories)
                    {
                        _directories.Add(Path.Combine(directory.TrimEnd('*'), path, "*"));
                    }
                }

                changes.AddAdded(directory, path);

                var newFileState = new FileState(directory, path);
                newFileState.LastWrite = file.LastWrite;
                newFileState.FileSize  = file.FileSize;
                newFileState._version  = _version;
                _state.Add(directory, path, newFileState);
                return;
            }

            _state.Values[index]._version = _version;

            if (file.IsDirectory)
            {
                return;
            }

            var previousState = _state.Values[index];

            if (file.LastWrite != previousState.LastWrite || file.FileSize != previousState.FileSize)
            {
                changes.AddChanged(directory, previousState.Path);
                _state.Values[index].LastWrite = file.LastWrite;
                _state.Values[index].FileSize  = file.FileSize;
            }
        }
        public void Add(string directory, string file, FileState value)
        {
            if (_nextValuesIndex >= Values.Length) // Resize
            {
                Resize();
            }

            Values[_nextValuesIndex] = value;
            var bucket = ComputeBucket(file);

            while (true)
            {
                if (Buckets[bucket].IsEmpty)
                {
                    Buckets[bucket] = new Bucket(directory, file, _nextValuesIndex);
                    _count++;
                    _nextValuesIndex++;
                    return;
                }
                bucket = NextCandidateBucket(bucket);
            }
        }