コード例 #1
0
ファイル: Mirror.cs プロジェクト: haides/CmisDrive
        public NtStatus MoveFile(string oldName, string newName, bool replace, DokanFileInfo info)
        {
            string oldpath = oldName.Replace("\\", "/");
            string newpath = newName.Replace("\\", "/");

            ICmisObject oldObject = cmisSession.GetObjectByPath(oldpath);

            oldObject.Rename(newpath);

            /*bool exist = false;  // TODO replace the quick implementation above by something more like the decision tree below
             * if (info.IsDirectory)
             *  exist = Directory.Exists(newpath);
             * else
             *  exist = File.Exists(newpath);
             *
             * if (!exist)
             * {
             *  info.Context = null;
             *  if (info.IsDirectory)
             *      Directory.Move(oldpath, newpath);
             *  else
             *      File.Move(oldpath, newpath);
             *  return Trace("MoveFile", oldName, info, DokanResult.Success, newName, replace.ToString(CultureInfo.InvariantCulture));
             * }
             * else if (replace)
             * {
             *  info.Context = null;
             *
             *  if (!info.IsDirectory)
             *      File.Delete(newpath);
             *  else
             *      Directory.Delete(newpath, true);
             *
             *  if (info.IsDirectory)
             *      Directory.Move(oldpath, newpath);
             *  else
             *      File.Move(oldpath, newpath);
             *  return Trace("MoveFile", oldName, info, DokanResult.Success, newName, replace.ToString(CultureInfo.InvariantCulture));
             * }*/
            return(Trace("MoveFile", oldName, info, DokanResult.FileExists, newName, replace.ToString(CultureInfo.InvariantCulture)));
        }