/* Perform our quick-check heuristic for determining if a file is unchanged. */ public bool UnchangedFile(string fileName, FileStruct file) { // TODO: path length if (!File.Exists(fileName)) { return(false); } FileInfo fi = new FileInfo(fileName); // TODO: path length if (fi.Length != file.length) { return(false); } /* if always checksum is set then we use the checksum instead * of the file time to determine whether to sync */ if (options.alwaysChecksum) { byte[] sum = new byte[CheckSum.MD4_SUM_LENGTH]; // TODO: path length checkSum.FileCheckSum(fileName, ref sum, (int)fi.Length); return(Util.MemoryCompare(sum, 0, file.sum, 0, options.protocolVersion < 21 ? 2 : CheckSum.MD4_SUM_LENGTH) == 0); } if (options.sizeOnly) { return(true); } if (options.ignoreTimes) { return(false); } // TODO: path length return(Util.CompareModificationTime(fi.LastWriteTime.Second, file.modTime.Second, options) == 0); }
/* Perform our quick-check heuristic for determining if a file is unchanged. */ public bool UnchangedFile(string fileName, FileStruct file) { // TODO: path length if (!File.Exists(fileName)) { return(false); } var fi = new FileInfo(fileName); // TODO: path length if (fi.Length != file.Length) { return(false); } /* if always checksum is set then we use the checksum instead * of the file time to determine whether to sync */ if (_options.AlwaysChecksum) { //byte[] sum = new byte[CheckSum.Md4SumLength]; // TODO: path length var sum = _checkSum.FileCheckSum(fileName, (int)fi.Length); return(Util.MemoryCompare(sum, 0, file.Sum, 0, _options.ProtocolVersion < 21 ? 2 : CheckSum.Md4SumLength) == 0); } if (_options.SizeOnly) { return(true); } if (_options.IgnoreTimes) { return(false); } // TODO: path length return(Util.CompareModificationTime(fi.LastWriteTime.Second, file.ModTime.Second, _options) == 0); }
/// <summary> /// Generates a FileStruct filled with all info /// </summary> /// <param name="fileName"></param> /// <param name="fileList"></param> /// <param name="excludeLevel"></param> /// <returns></returns> public FileStruct makeFile(string fileName, List <FileStruct> fileList, int excludeLevel) { if (string.IsNullOrEmpty(fileName)) { return(null); } string thisName = Util.cleanFileName(fileName, false); if (options.sanitizePath) //@todo_long It is useless for this moment { thisName = Util.sanitizePath(thisName, String.Empty, 0); } FileStruct fileStruct = new FileStruct(); // TODO: path length if (Directory.Exists(thisName)) { if (thisName.LastIndexOf('/') != -1) { thisName = thisName.TrimEnd('/'); fileStruct.dirName = thisName.Substring(0, thisName.LastIndexOf('/')).Replace(@"\", "/"); fileStruct.baseName = thisName.Substring(thisName.LastIndexOf('/') + 1); fileStruct.gid = 0; fileStruct.uid = 0; fileStruct.mode = 0x4000 | 0x16B; // TODO: path length DirectoryInfo di = new DirectoryInfo(thisName); if ((di.Attributes & FileAttributes.ReadOnly) != FileAttributes.ReadOnly) { fileStruct.mode |= 0x92; } } } // TODO: path length if (File.Exists(thisName)) { if (excludeLevel != Options.NO_EXCLUDES && checkExcludeFile(thisName, 0, excludeLevel)) { return(null); } fileStruct.baseName = Path.GetFileName(thisName); fileStruct.dirName = Path.GetDirectoryName(thisName).Replace(@"\", "/").TrimEnd('/'); FileInfo fi = new FileInfo(thisName); // TODO: path length fileStruct.length = (int)fi.Length; // TODO: path length fileStruct.modTime = fi.LastWriteTime; fileStruct.mode = 0x8000 | 0x1A4; // TODO: path length if ((File.GetAttributes(thisName) & FileAttributes.ReadOnly) != FileAttributes.ReadOnly) { fileStruct.mode |= 0x92; } fileStruct.gid = 0; fileStruct.uid = 0; int sum_len = options.alwaysChecksum ? CheckSum.MD4_SUM_LENGTH : 0; if (sum_len != 0) { if (!checkSum.FileCheckSum(thisName, ref fileStruct.sum, fileStruct.length)) { Log.Write("Skipping file " + thisName); return(null); } } Options.stats.totalSize += fileStruct.length; } fileStruct.baseDir = fileListDir; return(fileStruct); }
public FileStruct makeFile(string fileName, ArrayList fileList, int excludeLevel) { if (fileName == null || fileName.CompareTo("") == 0) { return(null); } string thisName = Util.cleanFileName(fileName, false); if (options.sanitizePath) { thisName = Util.sanitizePath(thisName, "", 0); } FileStruct fs = new FileStruct(); // TODO: path length if (FileSystem.Directory.Exists(thisName)) { if (thisName.LastIndexOf('/') != -1) { thisName = thisName.TrimEnd('/'); fs.dirName = thisName.Substring(0, thisName.LastIndexOf('/')).Replace(@"\", "/"); fs.baseName = thisName.Substring(thisName.LastIndexOf('/') + 1); fs.gid = 0; fs.uid = 0; fs.mode = 0x4000 | 0x16B; // TODO: path length FileSystem.DirectoryInfo di = new FileSystem.DirectoryInfo(thisName); if ((di.Attributes & FileAttributes.ReadOnly) != FileAttributes.ReadOnly) { fs.mode |= 0x92; } } } // TODO: path length if (FileSystem.File.Exists(thisName)) { if (excludeLevel != Options.NO_EXCLUDES && checkExcludeFile(thisName, 0, excludeLevel)) { return(null); } fs.baseName = Path.GetFileName(thisName); fs.dirName = FileSystem.Directory.GetDirectoryName(thisName).Replace(@"\", "/").TrimEnd('/'); FileSystem.FileInfo fi = new FileSystem.FileInfo(thisName); // TODO: path length fs.length = (int)fi.Length; // TODO: path length fs.modTime = fi.LastWriteTime; fs.mode = 0x8000 | 0x1A4; // TODO: path length if ((FileSystem.File.GetAttributes(thisName) & FileAttributes.ReadOnly) != FileAttributes.ReadOnly) { fs.mode |= 0x92; } fs.gid = 0; fs.uid = 0; int sum_len = options.alwaysChecksum ? CheckSum.MD4_SUM_LENGTH : 0; if (sum_len != 0) { if (!checkSum.FileCheckSum(thisName, ref fs.sum, fs.length)) { Log.Write("Skipping file " + thisName); return(null); } } Options.stats.totalSize += fs.length; } fs.baseDir = fileListDir; return(fs); }
/// <summary> /// Generates a FileStruct filled with all info /// </summary> /// <param name="fileName"></param> /// <param name="fileList"></param> /// <param name="excludeLevel"></param> /// <returns></returns> public FileStruct MakeFile(string fileName, List <FileStruct> fileList, int excludeLevel) { if (string.IsNullOrEmpty(fileName)) { return(null); } var thisName = Util.CleanFileName(fileName, false); if (_options.SanitizePath) //@todo_long It is useless for this moment { thisName = Util.SanitizePath(thisName, String.Empty, 0); } var fileStruct = new FileStruct(); // TODO: path length if (Directory.Exists(thisName)) { if (thisName.LastIndexOf('/') != -1) { thisName = thisName.TrimEnd('/'); fileStruct.DirName = thisName.Substring(0, thisName.LastIndexOf('/')).Replace(@"\", "/"); fileStruct.BaseName = thisName.Substring(thisName.LastIndexOf('/') + 1); fileStruct.Gid = 0; fileStruct.Uid = 0; fileStruct.Mode = 0x4000 | 0x16B; // TODO: path length var di = new DirectoryInfo(thisName); if ((di.Attributes & FileAttributes.ReadOnly) != FileAttributes.ReadOnly) { fileStruct.Mode |= 0x92; } } } // TODO: path length if (File.Exists(thisName)) { if (excludeLevel != Options.NoExcludes && CheckExcludeFile(thisName, 0, excludeLevel)) { return(null); } fileStruct.BaseName = Path.GetFileName(thisName); fileStruct.DirName = Path.GetFullPath(Path.GetDirectoryName(thisName)); var fi = new FileInfo(thisName); // TODO: path length fileStruct.Length = (int)fi.Length; // TODO: path length fileStruct.ModTime = fi.LastWriteTime; fileStruct.Mode = 0x8000 | 0x1A4; // TODO: path length if ((File.GetAttributes(thisName) & FileAttributes.ReadOnly) != FileAttributes.ReadOnly) { fileStruct.Mode |= 0x92; } fileStruct.Gid = 0; fileStruct.Uid = 0; var sumLen = _options.AlwaysChecksum ? CheckSum.Md4SumLength : 0; if (sumLen != 0 && (_checkSum.FileCheckSum(thisName, fileStruct.Length) != null)) { Log.Write("Skipping file " + thisName); return(null); } Options.Stats.TotalSize += fileStruct.Length; } fileStruct.BaseDir = _fileListDir; return(fileStruct); }