Exemple #1
0
        private bool DetectFileChange(out Encoding overwrittenEncoding)
        {
            overwrittenEncoding = null;
            if (!_filesystem.FileExists(_fullFilename))
            {
                if (_lastFingerprint != null)
                {
                    _lastFingerprint = null;
                    Log.DebugFormat("File {0} no longer exists", _fullFilename);
                    return(true);
                }

                return(false);
            }

            var currentFingerprint = FileFingerprint.FromFile(_filesystem, _fullFilename);

            if (!Equals(currentFingerprint, _lastFingerprint))
            {
                Log.DebugFormat("File {0} fingerprint changed from {1} to {2}", _fullFilename, _lastFingerprint, currentFingerprint);
                _lastFingerprint = currentFingerprint;
                return(true);
            }

            overwrittenEncoding = _properties.GetValue(TextProperties.OverwrittenEncoding);
            var currentEncoding = _properties.GetValue(TextProperties.Encoding);

            if (!Equals(overwrittenEncoding, null) && !Equals(overwrittenEncoding, currentEncoding))
            {
                Log.DebugFormat("File {0} user chose an overwritten encoding {1} which differs from the current encoding {2}", _fullFilename, overwrittenEncoding, overwrittenEncoding);
                return(true);
            }

            return(false);
        }
Exemple #2
0
        private bool HasFileChanged(out FileFingerprint currentFingerprint, out FileFingerprint lastFingerprint)
        {
            lastFingerprint    = _lastFingerprint;
            currentFingerprint = FileFingerprint.FromFile(_fileName);
            if (Equals(currentFingerprint, _lastFingerprint))
            {
                return(false);
            }

            _lastFingerprint = currentFingerprint;
            _propertiesBuffer.SetValue(Core.Properties.LastModified, currentFingerprint.LastModified);
            _propertiesBuffer.SetValue(Core.Properties.Created, currentFingerprint.Created);
            _propertiesBuffer.SetValue(Core.Properties.Size, Size.FromBytes(currentFingerprint.Size));
            return(true);
        }