Example #1
0
        //sb.Append(@"Unique=").Append(fileInfo.FullName.GetHashCode()).Append(';');
        //sb.Append(@"Media-Type=").Append(MimeTypeDetector(fileInfo)).Append(';');
        //   ClientSocket.WritePathNameCRLN(UseUTF8, info.Name);

        private FileSystemFTPInfo ParseLine(string features)
        {
            int nameStart = features.LastIndexOf(';');

            if ((features[0] != '5') &&
                (nameStart > 0)
                )
            {
                string            localUpper = features.ToUpper();
                string            name       = System.Text.Encoding.UTF8.GetString(System.Text.Encoding.Default.GetBytes(features.Substring(nameStart + 1).Trim()));
                string            newPath    = Path.Combine(path, name);
                FileSystemFTPInfo info;
                if (!localUpper.Contains(TYPE))
                {
                    info = new DirectoryFTPInfo(ftpCmdInstance, newPath);
                }
                else
                {
                    info = new FileFTPInfo(ftpCmdInstance, newPath);
                }
                info.name = name;
                int size = localUpper.LastIndexOf(SIZE);
                if (size > 0)
                {
                    size += 5; // Enough to step over the search text
                    long result;
                    if (long.TryParse(features.Substring(size, localUpper.IndexOf(';', size) - size), out result))
                    {
                        info.Length = result;
                    }
                }

                FileAttributes attributes = 0;
                int            win32ea    = localUpper.LastIndexOf(WIN32_EA);
                if (win32ea > 0)
                {
                    win32ea += 9; // Enough to step over the search text
                    if (localUpper[win32ea + 1] == 'X')
                    {
                        win32ea += 2;
                    }
                    UInt32 result;
                    if (UInt32.TryParse(features.Substring(win32ea, localUpper.IndexOf(';', win32ea) - win32ea),
                                        NumberStyles.AllowHexSpecifier, CultureInfo.InvariantCulture, out result))
                    {
                        attributes = (FileAttributes)result;
                    }
                }
                info.lastWriteTimeUtc = DecodeTime(localUpper, MODIFY);
                info.creationTimeUtc  = DecodeTime(localUpper, CREATE);
                if (attributes == 0)
                {
                    // TODO: Do this the hardway !
                    //sb.Append(@"Perm=");
                    //            sb.Append('w'); // that the STOR command may be applied to the object named
                    //      sb.Append('a'); // Indicates that the APPE (append) command may be applied to the file named.
                    //   }
                    //   if (ConnectedUser.CanRenameFiles)
                    //      sb.Append('f'); // Allow user to rename
                    //      sb.Append('c'); // It indicates that files may be created in the directory named.
                    //      sb.Append('m'); // MKD command may be used
                    //   }
                    //   if (ConnectedUser.CanDeleteFolders)
                    //   {
                    //      sb.Append('d'); // It indicates that the object named may be deleted
                    //      sb.Append('p'); // Directory can be Purged (Deleted)
                    //   }
                    //   if (ConnectedUser.CanRenameFolders)
                    //      sb.Append('f'); // Allow user to rename
                    //sb.Append('e');      // Allow user to Enter the directoy
                    //sb.Append(@"l;");      // Allow user to List the directoy
                    //}
                    //sb.Append("r;"); // indicates that the RETR command may be applied to that object
                }
                if (attributes == 0)
                {
                    attributes = (info is FileFTPInfo) ? FileAttributes.Normal : FileAttributes.Directory;
                }
                info.attributes = attributes;

                return(info);
            }
            return(null);
        }
 public OptimizedFTPFileReadHandler(ClientShareDetail csd, uint rawCreationDisposition, FileFTPInfo foundFileInfo, OptimizedFTPFileReadHandler cachedReadBuffer)
     : base(csd, rawCreationDisposition, foundFileInfo)
 {
     if ((cachedReadBuffer != null) &&
         (cachedReadBuffer.ftpReadBuffer != null)
         )
     {
         ftpReadBuffer = new FTPTempFile(true);
         cachedReadBuffer.ftpReadBuffer.Position = 0;
         cachedReadBuffer.ftpReadBuffer.IO.CopyTo(ftpReadBuffer.IO);
     }
 }
Example #3
0
 protected FileStreamFTP(ClientShareDetail csd, uint rawCreationDisposition, FileFTPInfo foundFileInfo)
 {
     this.csd = csd;
     this.rawCreationDisposition = rawCreationDisposition;
     fsi = foundFileInfo;
 }