From: Alex Vandiver Date: Mon, 11 Jul 2016 20:39:57 +0000 (-0700) Subject: Use phutil functions to copy/move files X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=8f69a5c378c317f0a85b33151ee769626c0ecf00;p=arcanist.git Use phutil functions to copy/move files Summary: The `cp` and `mv` commands, when run from a Windows environment, error out. Use library functions from `Filesystem` for cross-platform compatibility. Test Plan: Ran `arc lint` with auto-fix lint errors on both Linux and Windows. Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Spies: Korvin, epriestley Differential Revision: https://secure.phabricator.com/D16273 --- diff --git a/src/lint/ArcanistLintPatcher.php b/src/lint/ArcanistLintPatcher.php index 0147dd61..52292362 100644 --- a/src/lint/ArcanistLintPatcher.php +++ b/src/lint/ArcanistLintPatcher.php @@ -42,12 +42,13 @@ final class ArcanistLintPatcher extends Phobject { // supported under OSX. if (Filesystem::pathExists($path)) { // This path may not exist if we're generating a new file. - execx('cp -p %s %s', $path, $lint); + Filesystem::copyFile($path, $lint); } Filesystem::writeFile($lint, $data); - list($err) = exec_manual('mv -f %s %s', $lint, $path); - if ($err) { + try { + Filesystem::rename($lint, $path); + } catch (FilesystemException $e) { throw new Exception( pht( "Unable to overwrite path '%s', patched version was left at '%s'.",