diff options
| -rw-r--r-- | src/luarocks/fs/lua.lua | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/luarocks/fs/lua.lua b/src/luarocks/fs/lua.lua index 16af8ab1..91cabe51 100644 --- a/src/luarocks/fs/lua.lua +++ b/src/luarocks/fs/lua.lua | |||
| @@ -454,6 +454,10 @@ end | |||
| 454 | 454 | ||
| 455 | end | 455 | end |
| 456 | 456 | ||
| 457 | --------------------------------------------------------------------- | ||
| 458 | -- Other functions | ||
| 459 | --------------------------------------------------------------------- | ||
| 460 | |||
| 457 | --- Apply a patch. | 461 | --- Apply a patch. |
| 458 | -- @param patchname string: The filename of the patch. | 462 | -- @param patchname string: The filename of the patch. |
| 459 | function apply_patch(patchname, patchdata) | 463 | function apply_patch(patchname, patchdata) |
| @@ -466,6 +470,31 @@ function apply_patch(patchname, patchdata) | |||
| 466 | end | 470 | end |
| 467 | end | 471 | end |
| 468 | 472 | ||
| 473 | --- Move a file. | ||
| 474 | -- @param src string: Pathname of source | ||
| 475 | -- @param dest string: Pathname of destination | ||
| 476 | -- @return boolean or (boolean, string): true on success, false on failure, | ||
| 477 | -- plus an error message. | ||
| 478 | function move(src, dest) | ||
| 479 | assert(src and dest) | ||
| 480 | if fs.exists(dest) then | ||
| 481 | return false, "File already exists: "..dest | ||
| 482 | end | ||
| 483 | local ok, err = fs.copy(src, dest) | ||
| 484 | if not ok then | ||
| 485 | return false, err | ||
| 486 | end | ||
| 487 | ok = fs.delete(src) | ||
| 488 | if not ok then | ||
| 489 | return false, "Failed move: could not delete "..src.." after copy." | ||
| 490 | end | ||
| 491 | return true | ||
| 492 | end | ||
| 493 | |||
| 494 | --------------------------------------------------------------------- | ||
| 495 | -- TODO These still reference external binaries | ||
| 496 | --------------------------------------------------------------------- | ||
| 497 | |||
| 469 | --- Unpack an archive. | 498 | --- Unpack an archive. |
| 470 | -- Extract the contents of an archive, detecting its format by | 499 | -- Extract the contents of an archive, detecting its format by |
| 471 | -- filename extension. | 500 | -- filename extension. |
