Closed Bug 1650227 Opened 4 years ago Closed 4 years ago

Port OS.File move/rename to C++

Categories

(Toolkit Graveyard :: OS.File, task)

Tracking

(firefox80 fixed)

RESOLVED FIXED
mozilla80
Tracking Status
firefox80 --- fixed

People

(Reporter: mail, Assigned: mail)

References

Details

Attachments

(1 file)

Part of larger work to port OS.File to C++, we need a static method in the IOUtils interface which can move/rename files.

Assignee: nobody → krourke

This patch introduces a move method to the IOUtils interface, which allows
for renaming/moving files or directories on disk. Source and destination
files may be specified either by an absolute path, or a relative path from
the current working directory.

This method mimics the behaviour of the POSIX mv command and has
well-defined behaviour (regardless of whether the source
or destination is a file or directory), briefly summarized below:

  1. If the source is a file that exists:
    a. If the destination is a file that does not exist, but whose parent
    directory does exist, the source is renamed (and re-parented as a
    child of the destination parent directory).
    b. If the destination is a file that does exist, the destination is
    replaced with the source (unless the noOverwrite option is true).

  2. If the source is a directory that exists:
    a. If the destination is a directory, then the source directory is
    re-parented such that it becomes a child of the destination.
    b. If the destination does not exist, then the source is renamed.
    c. If the destination is a file, then an error occurs.

  3. If the source does not exist, an error occurs.

Blocks: 1650898
Type: defect → task
Pushed by brennie@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/d8930122993c
Implement IOUtils move method r=barret,Gijs

Backed out for bustage on IOUtils.cpp

backout: https://hg.mozilla.org/integration/autoland/rev/cfd5ede7df08452c898256f40dc3c90697689b5a

push: https://treeherder.mozilla.org/#/jobs?repo=autoland&searchStr=linux%2Cx64%2Cdebug%2Cbuild-linux64-base-toolchains%2Fdebug%2Cbb&revision=4a1958574a2f807015619444f79d3724a4959190

failure log: https://treeherder.mozilla.org/logviewer.html#/jobs?job_id=309786446&repo=autoland&lineNumber=10162

[task 2020-07-14T20:06:05.021Z] 20:06:05 INFO - In file included from Unified_cpp_dom_system0.cpp:2:0:
[task 2020-07-14T20:06:05.026Z] 20:06:05 INFO - /builds/worker/checkouts/gecko/dom/system/IOUtils.cpp: In function 'nsCString mozilla::dom::FormatErrorMessage(nsresult, const char*)':
[task 2020-07-14T20:06:05.026Z] 20:06:05 ERROR - /builds/worker/checkouts/gecko/dom/system/IOUtils.cpp:100:54: error: format '%x' expects argument of type 'unsigned int', but argument 4 has type 'nsresult' [-Werror=format=]
[task 2020-07-14T20:06:05.026Z] 20:06:05 INFO - return nsPrintfCString("%s: 0x%x", aMessage, aError);
[task 2020-07-14T20:06:05.026Z] 20:06:05 INFO -

Flags: needinfo?(krourke)
Pushed by brennie@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/ac36796cffa9
Implement IOUtils move method r=barret,Gijs

The bustage should be fixed now, sorry about that.

Flags: needinfo?(krourke)
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla80
Product: Toolkit → Toolkit Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: