Changeset View
Changeset View
Standalone View
Standalone View
src/lint/ArcanistLintPatcher.php
Show All 36 Lines | public function writePatchToDisk() { | ||||
do { | do { | ||||
$lint = $path.'.linted'.($ii++); | $lint = $path.'.linted'.($ii++); | ||||
} while (file_exists($lint)); | } while (file_exists($lint)); | ||||
// Copy existing file to preserve permissions. 'chmod --reference' is not | // Copy existing file to preserve permissions. 'chmod --reference' is not | ||||
// supported under OSX. | // supported under OSX. | ||||
if (Filesystem::pathExists($path)) { | if (Filesystem::pathExists($path)) { | ||||
// This path may not exist if we're generating a new file. | // This path may not exist if we're generating a new file. | ||||
if (phutil_is_windows()) { | |||||
execx('copy %s %s', $path, $lint); | |||||
} else { | |||||
execx('cp -p %s %s', $path, $lint); | execx('cp -p %s %s', $path, $lint); | ||||
} | } | ||||
} | |||||
Filesystem::writeFile($lint, $data); | Filesystem::writeFile($lint, $data); | ||||
if (phutil_is_windows()) { | |||||
list($err) = exec_manual('move /Y %s %s', $lint, $path); | |||||
} else { | |||||
list($err) = exec_manual('mv -f %s %s', $lint, $path); | list($err) = exec_manual('mv -f %s %s', $lint, $path); | ||||
} | |||||
if ($err) { | if ($err) { | ||||
throw new Exception( | throw new Exception( | ||||
pht( | pht( | ||||
"Unable to overwrite path '%s', patched version was left at '%s'.", | "Unable to overwrite path '%s', patched version was left at '%s'.", | ||||
$path, | $path, | ||||
$lint)); | $lint)); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 86 Lines • Show Last 20 Lines |