Ejemplo n.º 1
0
        public void outputFileList(List <FileStruct> fileList)
        {
            string uid = String.Empty, gid = String.Empty;

            for (int i = 0; i < fileList.Count; i++)
            {
                FileStruct file = fileList[i];
                if ((options.amRoot || options.amSender) && options.preserveUID)
                {
                    uid = " uid=" + file.uid;
                }
                if (options.preserveGID && file.gid != Options.GID_NONE)
                {
                    gid = " gid=" + file.gid;
                }
                Log.WriteLine("[" + options.WhoAmI() + "] i=" + i + " " + Util.NS(file.baseDir) + " " +
                              Util.NS(file.dirName) + " " + Util.NS(file.baseName) + " mode=0" + Convert.ToString(file.mode, 8) +
                              " len=" + file.length + uid + gid);
            }
        }
Ejemplo n.º 2
0
        public void sendFileName(IOStream ioStream, List <FileStruct> fileList, string fileName, bool recursive, UInt32 baseFlags)
        {
            FileStruct file = makeFile(fileName, fileList, ioStream == null && options.deleteExcluded ? Options.SERVER_EXCLUDES : Options.ALL_EXCLUDES);

            if (file == null)
            {
                return;
            }
            EmitFileListProgress(fileList);
            if (!string.IsNullOrEmpty(file.baseName))
            {
                fileList.Add(file);
                sendFileEntry(file, ioStream, baseFlags);

                if (recursive && Util.S_ISDIR(file.mode) && (file.flags & Options.FLAG_MOUNT_POINT) == 0)
                {
                    options.localExcludeList.Clear();
                    sendDirectory(ioStream, fileList, file.GetFullName());
                }
            }
        }
Ejemplo n.º 3
0
        public void sendFileName(IOStream f, ArrayList fileList, string fileName, bool recursive, UInt32 baseFlags)
        {
            FileStruct file = makeFile(fileName, fileList, f == null && options.deleteExcluded ? Options.SERVER_EXCLUDES : Options.ALL_EXCLUDES);

            if (file == null)
            {
                return;
            }
            mayBeEmitFileListProgress(fileList);
            if (file.baseName != null && file.baseName.CompareTo("") != 0)
            {
                fileList.Add(file);
                sendFileEntry(file, f, baseFlags);

                if (recursive && Util.S_ISDIR(file.mode) && (file.flags & Options.FLAG_MOUNT_POINT) == 0)
                {
                    options.localExcludeList.Clear();
                    sendDirectory(f, fileList, file.FNameTo());
                }
            }
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
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);
            }

            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);
        }
Ejemplo n.º 6
0
        public static int fileListFind(List <FileStruct> fileList, FileStruct file)
        {
            int low = 0, high = fileList.Count - 1;

            while (high >= 0 && (fileList[high]).baseName == null)
            {
                high--;
            }
            if (high < 0)
            {
                return(-1);
            }
            while (low != high)
            {
                int mid = (low + high) / 2;
                int ret = fileCompare(fileList[fileListUp(fileList, mid)], file);
                if (ret == 0)
                {
                    return(fileListUp(fileList, mid));
                }
                if (ret > 0)
                {
                    high = mid;
                }
                else
                {
                    low = mid + 1;
                }
            }

            if (fileCompare(fileList[fileListUp(fileList, low)], file) == 0)
            {
                return(fileListUp(fileList, low));
            }
            return(-1);
        }
Ejemplo n.º 7
0
		private void listFileEntry(FileStruct fileEntry)
		{
			if(fileEntry.baseName == null || fileEntry.baseName.CompareTo("") == 0)
				return;			
			string perms = "";			
			Log.WriteLine(perms + " " + fileEntry.length + " " + fileEntry.modTime.ToString() + " " + fileEntry.FNameTo());
		}
Ejemplo n.º 8
0
		public void sendFileEntry(FileStruct file, IOStream f, UInt32 baseflags)
		{
			UInt32 flags = baseflags;
			int l1 = 0,l2 = 0;

			if(f == null)
				return;
			if(file == null)
			{
				f.writeByte(0);
				lastName = "";
				return;
			}
			string fileName = file.FNameTo().Replace(":","");
			for (l1 = 0;
				lastName.Length >l1 && (fileName[l1] == lastName[l1]) && (l1 < 255);
				l1++) {}
			l2 = fileName.Substring(l1).Length;

			flags |= Options.XMIT_SAME_NAME;			

			if (l2 > 255)
				flags |= Options.XMIT_LONG_NAME; 
			if(options.protocolVersion >= 28)
			{
				if(flags == 0 && !Util.S_ISDIR(file.mode))
					flags |= Options.XMIT_TOP_DIR; 
				/*if ((flags & 0xFF00) > 0 || flags == 0) 
				{
					flags |= Options.XMIT_EXTENDED_FLAGS;
					f.writeByte((byte)flags);
					f.writeByte((byte)(flags >> 8));
				} 
				else					*/
					f.writeByte((byte)flags); 
			} else 
			{
				if ((flags & 0xFF) == 0 && !Util.S_ISDIR(file.mode))
					flags |= Options.XMIT_TOP_DIR;
				if ((flags & 0xFF) == 0)
					flags |= Options.XMIT_LONG_NAME;
				f.writeByte((byte)flags);
			}
			if ((flags & Options.XMIT_SAME_NAME) != 0)
				f.writeByte((byte)l1);
			if ((flags & Options.XMIT_LONG_NAME) != 0)
				f.writeInt(l2);
			else
				f.writeByte((byte)l2); 	
			
			
			byte[] b =System.Text.ASCIIEncoding.ASCII.GetBytes(fileName);

			f.Write(b, l1, l2);
			f.WriteLongInt(file.length); 

			
			if ((flags & Options.XMIT_SAME_TIME) == 0)
				f.writeInt(file.modTime.Second);
			if ((flags & Options.XMIT_SAME_MODE) == 0)
				f.writeInt((int)file.mode);
			if (options.preserveUID && (flags & Options.XMIT_SAME_UID) == 0) 
			{				
				f.writeInt(file.uid);
			}
			if (options.preserveGID && (flags & Options.XMIT_SAME_GID) == 0) 
			{				
				f.writeInt(file.gid);
			}
			if (options.alwaysChecksum ) 
			{
				byte[] sum;	
				if(!Util.S_ISDIR(file.mode))
					sum = file.sum;				
				else if(options.protocolVersion < 28)
					sum = new byte[16];
				else 
					sum = null;

				if (sum != null ) 
				{										
					f.Write(sum, 0, options.protocolVersion < 21 ? 2 : CheckSum.MD4_SUM_LENGTH);
				}

			}

			lastName = fileName;
		}
Ejemplo n.º 9
0
		public FileStruct receiveFileEntry(UInt32 flags, ClientInfo cInfo)
		{			
			if(cInfo == null)
			{
				lastName = "";
				return null;
			}
			IOStream f = cInfo.IoStream;

			int l1=0, l2=0;			
			
			if ((flags & Options.XMIT_SAME_NAME) != 0)
				l1 = f.readByte();

			if ((flags & Options.XMIT_LONG_NAME) != 0)
				l2 = f.readInt();
			else
				l2 = f.readByte();
			if (l2 >= Options.MAXPATHLEN - l1) 
			{				
				MainClass.Exit("overflow: lastname=" + lastName, cInfo);
			}

			string thisName = lastName.Substring(0, l1);			
			thisName += f.ReadSBuf(l2);
			lastName = thisName;
			
			thisName = Util.cleanFileName(thisName, false);
			if(options.sanitizePath)
				thisName = Util.sanitizePath(thisName, "", 0);

			string baseName = "";
			string dirName = "";			
			if (thisName.LastIndexOf("/") != -1) 
			{
				baseName = Path.GetFileName(thisName);				
				dirName = FileSystem.Directory.GetDirectoryName(thisName).Replace(@"\","/").Replace(":","");
			} 
			else 
			{
				baseName = thisName;
				dirName = null;
			}

			Int64 fileLength = f.ReadLongInt();
			
			if ((flags & Options.XMIT_SAME_TIME) == 0)
				modTime = DateTime.FromFileTime(f.readInt());
			if ((flags & Options.XMIT_SAME_MODE) == 0)				
				mode = (UInt32)f.readInt();

			if (options.preserveUID && (flags & Options.XMIT_SAME_UID) == 0)
			{
				int uid = f.readInt();
			}
			if (options.preserveGID && (flags & Options.XMIT_SAME_GID) == 0)
			{
				int gid = f.readInt();
			}

			byte[] sum = new byte[0];
			if (options.alwaysChecksum && !Util.S_ISDIR(mode)) 
			{		
				sum = new byte[CheckSum.MD4_SUM_LENGTH];										
				sum = f.ReadBuf(options.protocolVersion < 21 ? 2 : CheckSum.MD4_SUM_LENGTH);
			}
 
			FileStruct fs = new FileStruct();
			fs.length = (int)fileLength;
			fs.baseName = baseName;
			fs.dirName = dirName;
			fs.sum = sum;
			fs.mode = mode;
			fs.modTime = modTime;
			fs.flags = flags;
			return fs;
		}
Ejemplo n.º 10
0
 /// <summary>
 /// Empty method at this moment
 /// </summary>
 /// <param name="file"></param>
 /// <param name="initialStats"></param>
 public static void LogSend(FileStruct file, Stats initialStats)
 {
 }
Ejemplo n.º 11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="clientInfo"></param>
        /// <returns></returns>
        public List <FileStruct> receiveFileList(ClientInfo clientInfo)
        {
            IOStream          ioStream = clientInfo.IoStream;
            List <FileStruct> fileList = new List <FileStruct>();

            if (showFileListProgress())
            {
                startFileListProgress("receiving file list");
            }

            Int64 startRead = Options.stats.totalRead;

            UInt32 flags;

            while ((flags = ioStream.readByte()) != 0)
            {
                if (options.protocolVersion >= 28 && (flags & Options.XMIT_EXTENDED_FLAGS) != 0)
                {
                    flags |= (UInt32)(ioStream.readByte() << 8);
                }
                FileStruct file = receiveFileEntry(flags, clientInfo);
                if (file == null)
                {
                    continue;
                }
                fileList.Add(file);
                Options.stats.totalSize += (fileList[fileList.Count - 1]).length;
                EmitFileListProgress(fileList);
                if (options.verbose > 2)
                {
                    Log.WriteLine("receiveFileName(" + (fileList[fileList.Count - 1]).GetFullName() + ")");
                }
            }
            receiveFileEntry(0, null);

            if (options.verbose > 2)
            {
                Log.WriteLine("received " + fileList.Count + " names");
            }

            if (showFileListProgress())
            {
                finishFileListProgress(fileList);
            }

            cleanFileList(fileList, options.relativePaths, true);

            if (ioStream != null)
            {
                ioStream.readInt();
            }

            if (options.verbose > 3)
            {
                outputFileList(fileList);
            }
            if (options.listOnly)
            {
                logFileList(fileList);
            }
            if (options.verbose > 2)
            {
                Log.WriteLine("receiveFileList done");
            }

            Options.stats.fileListSize = (int)(Options.stats.totalRead - startRead);
            Options.stats.numFiles     = fileList.Count;
            return(fileList);
        }
Ejemplo n.º 12
0
        public void SendFileEntry(FileStruct file, IoStream ioStream, UInt32 baseflags)
        {
            var flags = baseflags;
            int l1 = 0, l2 = 0;

            if (ioStream == null)
            {
                return;
            }
            if (file == null)
            {
                ioStream.WriteByte(0);
                _lastName = String.Empty;
                return;
            }
            var fileName = file.GetFullName().Replace(":", String.Empty);

            for (l1 = 0;
                 _lastName.Length > l1 && (fileName[l1] == _lastName[l1]) && (l1 < 255);
                 l1++)
            {
            }
            l2 = fileName.Substring(l1).Length;

            flags |= Options.XmitSameName;

            if (l2 > 255)
            {
                flags |= Options.XmitLongName;
            }
            if (_options.ProtocolVersion >= 28)
            {
                if (flags == 0 && !Util.S_ISDIR(file.Mode))
                {
                    flags |= Options.XmitTopDir;
                }

                /*if ((flags & 0xFF00) > 0 || flags == 0)
                 * {
                 *  flags |= Options.XMIT_EXTENDED_FLAGS;
                 *  f.writeByte((byte)flags);
                 *  f.writeByte((byte)(flags >> 8));
                 * }
                 * else					*/
                ioStream.WriteByte((byte)flags);
            }
            else
            {
                if ((flags & 0xFF) == 0 && !Util.S_ISDIR(file.Mode))
                {
                    flags |= Options.XmitTopDir;
                }
                if ((flags & 0xFF) == 0)
                {
                    flags |= Options.XmitLongName;
                }
                ioStream.WriteByte((byte)flags);
            }
            if ((flags & Options.XmitSameName) != 0)
            {
                ioStream.WriteByte((byte)l1);
            }
            if ((flags & Options.XmitLongName) != 0)
            {
                ioStream.WriteInt(l2);
            }
            else
            {
                ioStream.WriteByte((byte)l2);
            }


            var b = Encoding.ASCII.GetBytes(fileName);

            ioStream.Write(b, l1, l2);
            ioStream.WriteLongInt(file.Length);


            if ((flags & Options.XmitSameTime) == 0)
            {
                ioStream.WriteInt(file.ModTime.Second);
            }
            if ((flags & Options.XmitSameMode) == 0)
            {
                ioStream.WriteInt((int)file.Mode);
            }
            if (_options.PreserveUid && (flags & Options.XmitSameUid) == 0)
            {
                ioStream.WriteInt(file.Uid);
            }
            if (_options.PreserveGid && (flags & Options.XmitSameGid) == 0)
            {
                ioStream.WriteInt(file.Gid);
            }
            if (_options.AlwaysChecksum)
            {
                byte[] sum;
                if (!Util.S_ISDIR(file.Mode))
                {
                    sum = file.Sum;
                }
                else if (_options.ProtocolVersion < 28)
                {
                    sum = new byte[16];
                }
                else
                {
                    sum = null;
                }

                if (sum != null)
                {
                    ioStream.Write(sum, 0, _options.ProtocolVersion < 21 ? 2 : CheckSum.Md4SumLength);
                }
            }

            _lastName = fileName;
        }
Ejemplo n.º 13
0
        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);
        }
Ejemplo n.º 14
0
        public ArrayList receiveFileList(ClientInfo cInfo)
        {
            IOStream  f        = cInfo.IoStream;
            ArrayList fileList = new ArrayList();

            if (showFileListP())
            {
                startFileListProgress("receiving file list");
            }

            Int64 startRead = Options.stats.totalRead;

            UInt32 flags;

            while ((flags = f.readByte()) != 0)
            {
                if (options.protocolVersion >= 28 && (flags & Options.XMIT_EXTENDED_FLAGS) != 0)
                {
                    flags |= (UInt32)(f.readByte() << 8);
                }
                FileStruct file = receiveFileEntry(flags, cInfo);
                if (file == null)
                {
                    continue;
                }
                fileList.Add(file);
                Options.stats.totalSize += ((FileStruct)fileList[fileList.Count - 1]).length;
                mayBeEmitFileListProgress(fileList);
                if (options.verbose > 2)
                {
                    Log.WriteLine("receiveFileName(" + ((FileStruct)fileList[fileList.Count - 1]).FNameTo() + ")");
                }
            }
            receiveFileEntry(0, null);

            if (options.verbose > 2)
            {
                Log.WriteLine("received " + fileList.Count + " names");
            }

            if (showFileListP())
            {
                finishFileListProgress(fileList);
            }

            cleanFileList(fileList, (options.relativePaths == 0) ? false : true, true);

            if (f != null)
            {
                f.readInt();
            }

            if (options.verbose > 3)
            {
                outputFileList(fileList);
            }
            if (options.listOnly)
            {
                for (int i = 0; i < fileList.Count; i++)
                {
                    listFileEntry((FileStruct)fileList[i]);
                }
            }
            if (options.verbose > 2)
            {
                Log.WriteLine("receiveFileList done");
            }

            Options.stats.flistSize = (int)(Options.stats.totalRead - startRead);
            Options.stats.numFiles  = fileList.Count;
            return(fileList);
        }
Ejemplo n.º 15
0
 public static int fileCompare(FileStruct file1, FileStruct file2)
 {
     return(uStringCompare(file1.FNameTo(), file2.FNameTo()));
 }
Ejemplo n.º 16
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;
            }

            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;
        }
Ejemplo n.º 17
0
        public void ReceiveGenerator(string fileName, FileStruct file, int i, IOStream f)
        {
            fileName = Path.Combine(options.dir, fileName);

            if (UnchangedFile(fileName, file))
            {
                return;
            }
            if (options.verbose > 2)
            {
                Log.WriteLine("Receive Generator(" + fileName + "," + i + ")\n");
            }
            int statRet;
            FStat st = new FStat();
            if (options.dryRun)
            {
                statRet = -1;
            }
            else
            {
                statRet = 0;
                try
                {
                    FileInfo fi = new FileInfo(fileName);
                    // TODO: path length
                    st.size = fi.Length;
                    // TODO: path length
                    st.mTime = fi.LastWriteTime;
                }
                catch
                {
                    statRet = -1;
                }
            }

            if (options.onlyExisting && statRet == -1)
            {
                /* we only want to update existing files */
                if (options.verbose > 1)
                {
                    Log.WriteLine("not creating new file \"" + fileName + "\"");
                }
                return;
            }
            string fNameCmp = fileName;
            if (options.wholeFile > 0)
            {
                f.writeInt(i);
                WriteSumHead(f, null);
                return;
            }
            FileStream fd;
            try
            {
                fd = new FileStream(fNameCmp, FileMode.Open, FileAccess.Read);
            }
            catch
            {
                if (options.verbose > 3)
                {
                    Log.WriteLine("failed to open " + Util.fullFileName(fNameCmp) + ", continuing");
                }
                f.writeInt(i);
                WriteSumHead(f, null);
                return;
            }

            if (options.verbose > 3)
            {
                Log.WriteLine("gen mapped " + fNameCmp + " of size " + st.size);
            }

            if (options.verbose > 2)
            {
                Log.WriteLine("generating and sending sums for " + i);
            }

            f.writeInt(i);
            Stream fCopy = null;
            GenerateAndSendSums(fd, st.size, f, fCopy);

            if (fCopy != null)
            {
                fCopy.Close();
            }
            fd.Close();
        }
Ejemplo n.º 18
0
        public void GenerateFiles(IOStream f, List <FileStruct> fileList, string localName)
        {
            int i;
            int phase = 0;


            if (options.verbose > 2)
            {
                Log.WriteLine("generator starting count=" + fileList.Count);
            }

            for (i = 0; i < fileList.Count; i++)
            {
                FileStruct file = (fileList[i]);
                if (file.baseName == null)
                {
                    continue;
                }
                if (Util.S_ISDIR(file.mode))
                {
                    continue;
                }
                ReceiveGenerator(localName != null ? localName : file.GetFullName(), file, i, f);
            }

            phase++;
            checkSum.length = CheckSum.SUM_LENGTH;
            if (options.verbose > 2)
            {
                Log.WriteLine("GenerateFiles phase=" + phase);
            }
            f.writeInt(-1);

            phase++;
            if (options.verbose > 2)
            {
                Log.WriteLine("GenerateFiles phase=" + phase);
            }

            f.writeInt(-1);

            if (options.protocolVersion >= 29 && !options.delayUpdates)
            {
                f.writeInt(-1);
            }

            /* now we need to fix any directory permissions that were
             * modified during the transfer
             * */
            for (i = 0; i < fileList.Count; i++)
            {
                FileStruct file = (fileList[i]);
                if (file.baseName != null || Util.S_ISDIR(file.mode))
                {
                    continue;
                }
                ReceiveGenerator(localName != null ? localName : file.GetFullName(), file, i, null);
            }

            if (options.verbose > 2)
            {
                Log.WriteLine("GenerateFiles finished");
            }
        }
Ejemplo n.º 19
0
 /// <summary>
 ///     Empty method at this moment
 /// </summary>
 /// <param name="file"></param>
 /// <param name="initialStats"></param>
 public static void LogSend(FileStruct file, Stats initialStats)
 {
 }
Ejemplo n.º 20
0
 public static void FinishTransfer(string fileName, string fileNameTmp, FileStruct file, bool okToSetTime)
 {
 }
Ejemplo n.º 21
0
        public void SendFiles(List <FileStruct> fileList, ClientInfo clientInfo)
        {
            ShowMessage("Processing...");
            try
            {
                IOStream  ioStream = clientInfo.IoStream;
                string    fileName = String.Empty, fileName2 = String.Empty;
                SumStruct s               = null;
                int       phase           = 0;
                bool      saveMakeBackups = options.makeBackups;
                Match     match           = new Match(options);

                if (options.verbose > 2)
                {
                    Log.WriteLine("SendFiles starting");
                }
                while (true)
                {
                    fileName = String.Empty;
                    int i = ioStream.readInt();
                    if (i == -1)
                    {
                        if (phase == 0)
                        {
                            phase++;
                            checkSum.length = CheckSum.SUM_LENGTH;
                            ioStream.writeInt(-1);
                            if (options.verbose > 2)
                            {
                                Log.WriteLine("SendFiles phase=" + phase);
                            }
                            options.makeBackups = false;
                            continue;
                        }
                        break;
                    }

                    if (i < 0 || i >= fileList.Count)
                    {
                        MainClass.Exit("Invalid file index " + i + " (count=" + fileList.Count + ")", clientInfo);
                    }

                    FileStruct file = fileList[i];

                    Options.stats.currentFileIndex = i;
                    Options.stats.numTransferredFiles++;
                    Options.stats.totalTransferredSize += file.length;

                    if (!string.IsNullOrEmpty(file.baseDir))
                    {
                        fileName = file.baseDir;
                        if (!fileName.EndsWith("/"))
                        {
                            fileName += "/";
                        }
                    }
                    fileName2 = file.GetFullName();
                    fileName += file.GetFullName();
                    ShowMessage("uploading " + fileName);

                    if (options.verbose > 2)
                    {
                        Log.WriteLine("sendFiles(" + i + ", " + fileName + ")");
                    }

                    if (options.dryRun)
                    {
                        if (!options.amServer && options.verbose != 0)
                        {
                            Log.WriteLine(fileName2);
                        }
                        ioStream.writeInt(i);
                        continue;
                    }

                    Stats initialStats = Options.stats;
                    s = ReceiveSums(clientInfo);

                    Stream fd;
                    try
                    {
                        fd = new FileStream(fileName, FileMode.Open, FileAccess.Read);
                    }
                    catch (FileNotFoundException)
                    {
                        Log.WriteLine("file has vanished: " + Util.fullFileName(fileName));
                        s = null;
                        continue;
                    }
                    catch (Exception)
                    {
                        Log.WriteLine("SendFiles failed to open " + Util.fullFileName(fileName));
                        s = null;
                        continue;
                    }

                    FStat    st = new FStat();
                    FileInfo fi = new FileInfo(fileName);
                    // TODO: path length
                    st.mTime = fi.LastWriteTime;
                    // TODO: path length
                    st.size = fi.Length;

                    MapFile mbuf = null;
                    if (st.size != 0)
                    {
                        int mapSize = (int)Math.Max(s.bLength * 3, Options.MAX_MAP_SIZE);
                        mbuf = new MapFile(fd, (int)st.size, mapSize, (int)s.bLength);
                    }

                    if (options.verbose > 2)
                    {
                        Log.WriteLine("SendFiles mapped " + fileName + " of size " + st.size);
                    }

                    ioStream.writeInt(i);
                    Generator gen = new Generator(options);
                    gen.WriteSumHead(ioStream, s);

                    if (options.verbose > 2)
                    {
                        Log.WriteLine("calling MatchSums " + fileName);
                    }

                    if (!options.amServer && options.verbose != 0)
                    {
                        Log.WriteLine(fileName2);
                    }

                    Token token = new Token(options);
                    token.SetCompression(fileName);

                    match.MatchSums(ioStream, s, mbuf, (int)st.size);
                    Log.LogSend(file, initialStats);

                    if (mbuf != null)
                    {
                        bool j = mbuf.UnMapFile();
                        if (j)
                        {
                            Log.WriteLine("read errors mapping " + Util.fullFileName(fileName));
                        }
                    }
                    fd.Close();

                    s.sums = null;

                    if (options.verbose > 2)
                    {
                        Log.WriteLine("sender finished " + fileName);
                    }
                }
                options.makeBackups = saveMakeBackups;

                if (options.verbose > 2)
                {
                    Log.WriteLine("send files finished");
                }

                match.MatchReport(ioStream);
                ioStream.writeInt(-1);
            }
            finally
            {
                HideMessage();
            }
        }
Ejemplo n.º 22
0
        public FileStruct ReceiveFileEntry(UInt32 flags, ClientInfo clientInfo)
        {
            if (clientInfo == null)
            {
                _lastName = String.Empty;
                return(null);
            }
            var f = clientInfo.IoStream;

            int l1 = 0, l2 = 0;

            if ((flags & Options.XmitSameName) != 0)
            {
                l1 = f.ReadByte();
            }

            if ((flags & Options.XmitLongName) != 0)
            {
                l2 = f.ReadInt();
            }
            else
            {
                l2 = f.ReadByte();
            }
            if (l2 >= Options.Maxpathlen - l1)
            {
                WinRsync.Exit("overflow: lastname=" + _lastName, clientInfo);
            }

            var thisName = _lastName.Substring(0, l1);

            thisName += f.ReadStringFromBuffer(l2);
            _lastName = thisName;

            thisName = Util.CleanFileName(thisName, false);
            if (_options.SanitizePath)
            {
                thisName = Util.SanitizePath(thisName, String.Empty, 0);
            }

            var baseName = String.Empty;
            var dirName  = String.Empty;

            if (thisName.LastIndexOf("/") != -1)
            {
                baseName = Path.GetFileName(thisName);
                dirName  = Path.GetDirectoryName(thisName);
            }
            else
            {
                baseName = thisName;
                dirName  = null;
            }

            var fileLength = f.ReadLongInt();

            if ((flags & Options.XmitSameTime) == 0)
            {
                _modTime = DateTime.FromFileTime(f.ReadInt());
            }
            if ((flags & Options.XmitSameMode) == 0)
            {
                _mode = (UInt32)f.ReadInt();
            }

            if (_options.PreserveUid && (flags & Options.XmitSameUid) == 0)
            {
                var uid = f.ReadInt();
            }
            if (_options.PreserveGid && (flags & Options.XmitSameGid) == 0)
            {
                var gid = f.ReadInt();
            }

            var sum = new byte[0];

            if (_options.AlwaysChecksum && !Util.S_ISDIR(_mode))
            {
                sum = new byte[CheckSum.Md4SumLength];
                sum = f.ReadBuffer(_options.ProtocolVersion < 21 ? 2 : CheckSum.Md4SumLength);
            }

            var fs = new FileStruct();

            fs.Length   = (int)fileLength;
            fs.BaseName = baseName;
            fs.DirName  = dirName;
            fs.Sum      = sum;
            fs.Mode     = _mode;
            fs.ModTime  = _modTime;
            fs.Flags    = flags;
            return(fs);
        }
Ejemplo n.º 23
0
 public static void FinishTransfer(string fileName, string fileNameTmp, FileStruct file, bool okToSetTime)
 {
 }
Ejemplo n.º 24
0
        public FileStruct receiveFileEntry(UInt32 flags, ClientInfo clientInfo)
        {
            if (clientInfo == null)
            {
                lastName = String.Empty;
                return(null);
            }
            IOStream f = clientInfo.IoStream;

            int l1 = 0, l2 = 0;

            if ((flags & Options.XMIT_SAME_NAME) != 0)
            {
                l1 = f.readByte();
            }

            if ((flags & Options.XMIT_LONG_NAME) != 0)
            {
                l2 = f.readInt();
            }
            else
            {
                l2 = f.readByte();
            }
            if (l2 >= Options.MAXPATHLEN - l1)
            {
                MainClass.Exit("overflow: lastname=" + lastName, clientInfo);
            }

            string thisName = lastName.Substring(0, l1);

            thisName += f.ReadStringFromBuffer(l2);
            lastName  = thisName;

            thisName = Util.cleanFileName(thisName, false);
            if (options.sanitizePath)
            {
                thisName = Util.sanitizePath(thisName, String.Empty, 0);
            }

            string baseName = String.Empty;
            string dirName  = String.Empty;

            if (thisName.LastIndexOf("/") != -1)
            {
                baseName = Path.GetFileName(thisName);
                dirName  = Path.GetDirectoryName(thisName);
            }
            else
            {
                baseName = thisName;
                dirName  = null;
            }

            Int64 fileLength = f.ReadLongInt();

            if ((flags & Options.XMIT_SAME_TIME) == 0)
            {
                modTime = DateTime.FromFileTime(f.readInt());
            }
            if ((flags & Options.XMIT_SAME_MODE) == 0)
            {
                mode = (UInt32)f.readInt();
            }

            if (options.preserveUID && (flags & Options.XMIT_SAME_UID) == 0)
            {
                int uid = f.readInt();
            }
            if (options.preserveGID && (flags & Options.XMIT_SAME_GID) == 0)
            {
                int gid = f.readInt();
            }

            byte[] sum = new byte[0];
            if (options.alwaysChecksum && !Util.S_ISDIR(mode))
            {
                sum = new byte[CheckSum.MD4_SUM_LENGTH];
                sum = f.ReadBuffer(options.protocolVersion < 21 ? 2 : CheckSum.MD4_SUM_LENGTH);
            }

            FileStruct fs = new FileStruct();

            fs.length   = (int)fileLength;
            fs.baseName = baseName;
            fs.dirName  = dirName;
            fs.sum      = sum;
            fs.mode     = mode;
            fs.modTime  = modTime;
            fs.flags    = flags;
            return(fs);
        }
Ejemplo n.º 25
0
 public static int fileCompare(FileStruct file1, FileStruct file2)
 {
     return(uStringCompare(file1.GetFullName(), file2.GetFullName()));
 }
Ejemplo n.º 26
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);
            }
            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);
        }
Ejemplo n.º 27
0
		public static int fileCompare(FileStruct file1, FileStruct file2)
		{			
			return uStringCompare(file1.FNameTo(),file2.FNameTo());			
		}
Ejemplo n.º 28
0
        public void ReceiveGenerator(string fileName, FileStruct file, int i, IOStream f)
        {
            fileName = Path.Combine(options.dir, fileName);

            if (UnchangedFile(fileName, file))
            {
                return;
            }
            if (options.verbose > 2)
            {
                Log.WriteLine("Receive Generator(" + fileName + "," + i + ")\n");
            }
            int   statRet;
            FStat st = new FStat();

            if (options.dryRun)
            {
                statRet = -1;
            }
            else
            {
                statRet = 0;
                try
                {
                    FileInfo fi = new FileInfo(fileName);
                    // TODO: path length
                    st.size = fi.Length;
                    // TODO: path length
                    st.mTime = fi.LastWriteTime;
                }
                catch
                {
                    statRet = -1;
                }
            }

            if (options.onlyExisting && statRet == -1)
            {
                /* we only want to update existing files */
                if (options.verbose > 1)
                {
                    Log.WriteLine("not creating new file \"" + fileName + "\"");
                }
                return;
            }
            string fNameCmp = fileName;

            if (options.wholeFile > 0)
            {
                f.writeInt(i);
                WriteSumHead(f, null);
                return;
            }
            FileStream fd;

            try
            {
                fd = new FileStream(fNameCmp, FileMode.Open, FileAccess.Read);
            }
            catch
            {
                if (options.verbose > 3)
                {
                    Log.WriteLine("failed to open " + Util.fullFileName(fNameCmp) + ", continuing");
                }
                f.writeInt(i);
                WriteSumHead(f, null);
                return;
            }

            if (options.verbose > 3)
            {
                Log.WriteLine("gen mapped " + fNameCmp + " of size " + st.size);
            }

            if (options.verbose > 2)
            {
                Log.WriteLine("generating and sending sums for " + i);
            }

            f.writeInt(i);
            Stream fCopy = null;

            GenerateAndSendSums(fd, st.size, f, fCopy);

            if (fCopy != null)
            {
                fCopy.Close();
            }
            fd.Close();
        }
Ejemplo n.º 29
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);
        }
Ejemplo n.º 30
0
		public static int fileListFind(ArrayList fileList, FileStruct file)
		{
			int low = 0, high = fileList.Count - 1;
			while(high >= 0 && ((FileStruct)fileList[high]).baseName == null) high--;
			if (high < 0)
				return -1;
			while(low != high)
			{
				int mid = (low + high) / 2;
				int ret = fileCompare((FileStruct)fileList[fileListUp(fileList, mid)],file);
				if(ret == 0)
					return fileListUp(fileList,mid);
				if(ret > 0)
					high = mid;
				else
					low = mid + 1;
			}

			if(fileCompare((FileStruct)fileList[fileListUp(fileList, low)],file) == 0)
				return fileListUp(fileList, low);
			return -1;
		}
Ejemplo n.º 31
0
        public void sendFileEntry(FileStruct file, IOStream ioStream, UInt32 baseflags)
        {
            UInt32 flags = baseflags;
            int    l1 = 0, l2 = 0;

            if (ioStream == null)
            {
                return;
            }
            if (file == null)
            {
                ioStream.writeByte(0);
                lastName = String.Empty;
                return;
            }
            string fileName = file.GetFullName().Replace(":", String.Empty);

            for (l1 = 0;
                 lastName.Length > l1 && (fileName[l1] == lastName[l1]) && (l1 < 255);
                 l1++)
            {
            }
            l2 = fileName.Substring(l1).Length;

            flags |= Options.XMIT_SAME_NAME;

            if (l2 > 255)
            {
                flags |= Options.XMIT_LONG_NAME;
            }
            if (options.protocolVersion >= 28)
            {
                if (flags == 0 && !Util.S_ISDIR(file.mode))
                {
                    flags |= Options.XMIT_TOP_DIR;
                }

                /*if ((flags & 0xFF00) > 0 || flags == 0)
                 * {
                 *  flags |= Options.XMIT_EXTENDED_FLAGS;
                 *  f.writeByte((byte)flags);
                 *  f.writeByte((byte)(flags >> 8));
                 * }
                 * else					*/
                ioStream.writeByte((byte)flags);
            }
            else
            {
                if ((flags & 0xFF) == 0 && !Util.S_ISDIR(file.mode))
                {
                    flags |= Options.XMIT_TOP_DIR;
                }
                if ((flags & 0xFF) == 0)
                {
                    flags |= Options.XMIT_LONG_NAME;
                }
                ioStream.writeByte((byte)flags);
            }
            if ((flags & Options.XMIT_SAME_NAME) != 0)
            {
                ioStream.writeByte((byte)l1);
            }
            if ((flags & Options.XMIT_LONG_NAME) != 0)
            {
                ioStream.writeInt(l2);
            }
            else
            {
                ioStream.writeByte((byte)l2);
            }


            byte[] b = System.Text.ASCIIEncoding.ASCII.GetBytes(fileName);

            ioStream.Write(b, l1, l2);
            ioStream.WriteLongInt(file.length);


            if ((flags & Options.XMIT_SAME_TIME) == 0)
            {
                ioStream.writeInt(file.modTime.Second);
            }
            if ((flags & Options.XMIT_SAME_MODE) == 0)
            {
                ioStream.writeInt((int)file.mode);
            }
            if (options.preserveUID && (flags & Options.XMIT_SAME_UID) == 0)
            {
                ioStream.writeInt(file.uid);
            }
            if (options.preserveGID && (flags & Options.XMIT_SAME_GID) == 0)
            {
                ioStream.writeInt(file.gid);
            }
            if (options.alwaysChecksum)
            {
                byte[] sum;
                if (!Util.S_ISDIR(file.mode))
                {
                    sum = file.sum;
                }
                else if (options.protocolVersion < 28)
                {
                    sum = new byte[16];
                }
                else
                {
                    sum = null;
                }

                if (sum != null)
                {
                    ioStream.Write(sum, 0, options.protocolVersion < 21 ? 2 : CheckSum.MD4_SUM_LENGTH);
                }
            }

            lastName = fileName;
        }
Ejemplo n.º 32
0
		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;
		}