Merge branch 'master' of github.com:Araq/Nimrod

This commit is contained in:
Araq 2011-11-30 19:52:09 +01:00
commit 9e5aee62a4

View file

@ -230,6 +230,27 @@ proc createDir*(ftp: var TFTPClient, dir: string, recursive: bool = false) =
previousDirs.add('/') previousDirs.add('/')
assertReply reply, "257" assertReply reply, "257"
proc chmod*(ftp: var TFTPClient, path: string,
permissions: set[TFilePermission]) =
## Changes permission of ``path`` to ``permissions``.
var userOctal = 0
var groupOctal = 0
var otherOctal = 0
for i in items(permissions):
case i
of fpUserExec: userOctal.inc(1)
of fpUserWrite: userOctal.inc(2)
of fpUserRead: userOctal.inc(4)
of fpGroupExec: groupOctal.inc(1)
of fpGroupWrite: groupOctal.inc(2)
of fpGroupRead: groupOctal.inc(4)
of fpOthersExec: otherOctal.inc(1)
of fpOthersWrite: otherOctal.inc(2)
of fpOthersRead: otherOctal.inc(4)
var perm = $userOctal & $groupOctal & $otherOctal
assertReply ftp.send("SITE CHMOD " & perm & " " & path), "200"
proc list*(ftp: var TFTPClient, dir: string = "", async = false): string = proc list*(ftp: var TFTPClient, dir: string = "", async = false): string =
## Lists all files in ``dir``. If ``dir`` is ``""``, uses the current ## Lists all files in ``dir``. If ``dir`` is ``""``, uses the current
## working directory. If ``async`` is true, this function will return ## working directory. If ``async`` is true, this function will return
@ -314,7 +335,7 @@ proc asyncUpload(ftp: var TFTPClient, timeout: int): bool =
ftp.job.dsockClosed = true ftp.job.dsockClosed = true
return return
if ftp.dsock.send(addr(buffer), len) != len: if ftp.dsock.send(addr(buffer), len) != len:
raise newException(EIO, "could not 'send' all data.") raise newException(EIO, "could not 'send' all data.")
ftp.job.progress.inc(len) ftp.job.progress.inc(len)