Пример #1
0
    // Pfm.FormatterDispatch.MoveReplace
    // Delete a previously opened target file and move a
    // previously opened source file to the target file name.
    public void MoveReplace(Pfm.MarshallerMoveReplaceOp op)
    {
        long   sourceOpenId       = op.SourceOpenId();
        long   sourceParentFileId = op.SourceParentFileId();
        string sourceEndName      = op.SourceEndName();
        long   targetOpenId       = op.TargetOpenId();
        long   targetParentFileId = op.TargetParentFileId();
        string targetEndName      = op.TargetEndName();
        bool   deleteSource       = op.DeleteSource();
        long   writeTime          = op.WriteTime();
        int    perr;
        File   sourceFile;
        File   sourceParent = null;
        File   targetFile   = null;
        File   targetParent = null;

        perr = FileFindOpenId(sourceOpenId, out sourceFile);
        if (perr == 0)
        {
            perr = FileFindFileId(sourceParentFileId, out sourceParent);
        }
        if (perr == 0)
        {
            perr = FileFindOpenId(targetOpenId, out targetFile);
        }
        if (perr == 0)
        {
            perr = FileFindFileId(targetParentFileId, out targetParent);
        }
        if (perr == 0)
        {
            perr = FileNameRemove(targetParent, writeTime, targetEndName, targetFile);
        }
        if (perr == 0)
        {
            FileNameAdd(targetParent, writeTime, targetEndName, sourceFile);
        }
        if (perr == 0 && deleteSource)
        {
            FileNameRemove(sourceParent, writeTime, sourceEndName, sourceFile);
        }

        op.Complete(perr);
    }
Пример #2
0
 public void MoveReplace(Pfm.MarshallerMoveReplaceOp op)
 {
     op.Complete(Pfm.errorAccessDenied);
 }