Exemple #1
0
        internal void UpdateState(string directory, ref FileChangeList changes, ref FileSystemEntry file)
        {
            int index = _state.IndexOf(directory, file.FileName);

            if (index == -1) // file added
            {
                string path = file.FileName.ToString();

                changes.AddAdded(directory, path.ToString());

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

            _state.Values[index]._version = _version;

            var previousState = _state.Values[index];

            if (file.LastWriteTimeUtc != previousState.LastWriteTimeUtc || file.Length != previousState.Length)
            {
                changes.AddChanged(directory, previousState.Path);
                _state.Values[index].LastWriteTimeUtc = file.LastWriteTimeUtc;
                _state.Values[index].Length           = file.Length;
            }
        }
Exemple #2
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;
            }
        }