Exemplo n.º 1
0
 private static void ProcessMove(SerializedCommand command)
 {
     if (VirtualDrive.ExistsDirectory(command.Data[0]))
     {
         //CoreVirtualDrive.FileSystemOperations.SafeOperations.MoveDirectory(command.Data[0], command.Data[1]);
         VirtualDrive.MoveDirectory(command.Data[0], command.Data[1]);
     }
     else if (VirtualDrive.ExistsFile(command.Data[0]))
     {
         //CoreVirtualDrive.FileSystemOperations.SafeOperations.MoveFile(command.Data[0], command.Data[1]);
         VirtualDrive.MoveFile(command.Data[0], command.Data[1]);
     }
     else
     {
         throw new Exception("\"" + command.Data[0] + "\" does not exist!");
     }
 }
Exemplo n.º 2
0
Arquivo: Lib.cs Projeto: MRoc/puremp3
        private void Rename(DirectoryInfo directory, FileInfo fileInfo)
        {
            Tag tag = TagUtils.ReadTag(fileInfo);

            string pathString = directory.FullName + Path.DirectorySeparatorChar;
            string newName    = new FileNameGenerator().Name(tag);
            string dst        = pathString + newName;
            string src        = fileInfo.FullName;

            int maxLength = 240;

            if (dst.Length >= maxLength)
            {
                newName = new FileNameGenerator().NameLimited(tag, maxLength - pathString.Length);
                dst     = pathString + newName;
            }

            if (fileInfo.Name.ToLower() != newName.ToLower())
            {
                int sLen = src.Length;
                int dLen = dst.Length;

                if (sLen <= maxLength && dLen <= maxLength)
                {
                    Logger.WriteLine(Tokens.InfoVerbose, "RENAME " + newName);
                    VirtualDrive.MoveDirectory(src, dst);
                }
                else
                {
                    Logger.WriteLine(Tokens.InfoVerbose, "SKIPPED " + fileInfo.FullName + "(TOO LONG");
                }
            }
            else
            {
                Logger.WriteLine(Tokens.InfoVerbose, "SKIPPED " + fileInfo.FullName);
            }
        }