mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-05 20:47:53 +00:00
Fix a few more warnings
This commit is contained in:
@@ -630,13 +630,13 @@ proc callCCompiler*(projectfile: string) =
|
||||
res = execWithEcho(cmds[i])
|
||||
if res != 0: rawMessage(errExecutionOfProgramFailed, [])
|
||||
elif optListCmd in gGlobalOptions or gVerbosity > 1:
|
||||
res = execProcesses(cmds, {poEchoCmd, poUseShell, poParentStreams},
|
||||
res = execProcesses(cmds, {poEchoCmd, poUsePath, poParentStreams},
|
||||
gNumberOfProcessors)
|
||||
elif gVerbosity == 1:
|
||||
res = execProcesses(cmds, {poUseShell, poParentStreams},
|
||||
res = execProcesses(cmds, {poUsePath, poParentStreams},
|
||||
gNumberOfProcessors, prettyCb)
|
||||
else:
|
||||
res = execProcesses(cmds, {poUseShell, poParentStreams},
|
||||
res = execProcesses(cmds, {poUsePath, poParentStreams},
|
||||
gNumberOfProcessors)
|
||||
if res != 0:
|
||||
if gNumberOfProcessors <= 1:
|
||||
|
||||
@@ -462,7 +462,7 @@ proc matchUserTypeClass*(c: PContext, m: var TCandidate,
|
||||
openScope(c)
|
||||
inc c.inTypeClass
|
||||
|
||||
finally:
|
||||
defer:
|
||||
dec c.inTypeClass
|
||||
closeScope(c)
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ proc readOutput(p: Process): string =
|
||||
discard p.waitForExit
|
||||
|
||||
proc opGorge*(cmd, input: string): string =
|
||||
var p = startCmd(cmd)
|
||||
var p = startProcess(cmd, options={poEvalCommand})
|
||||
if input.len != 0:
|
||||
p.inputStream.write(input)
|
||||
p.inputStream.close()
|
||||
|
||||
@@ -200,7 +200,7 @@ template schedule =
|
||||
if minIdx >= 0:
|
||||
p.actors[minIdx].i.send(t)
|
||||
else:
|
||||
raise newException(EDeadThread, "cannot send message; thread died")
|
||||
raise newException(DeadThreadError, "cannot send message; thread died")
|
||||
|
||||
proc spawn*[TIn, TOut](p: var TActorPool[TIn, TOut], input: TIn,
|
||||
action: proc (input: TIn): TOut {.thread.}
|
||||
|
||||
@@ -35,7 +35,7 @@ type
|
||||
offset: int64
|
||||
|
||||
when defined(windows):
|
||||
proc getDesiredAccess(mode: TFileMode): int32 =
|
||||
proc getDesiredAccess(mode: FileMode): int32 =
|
||||
case mode
|
||||
of fmRead:
|
||||
result = GENERIC_READ
|
||||
@@ -44,7 +44,7 @@ when defined(windows):
|
||||
of fmReadWrite, fmReadWriteExisting:
|
||||
result = GENERIC_READ or GENERIC_WRITE
|
||||
|
||||
proc getCreationDisposition(mode: TFileMode, filename: string): int32 =
|
||||
proc getCreationDisposition(mode: FileMode, filename: string): int32 =
|
||||
case mode
|
||||
of fmRead, fmReadWriteExisting:
|
||||
OPEN_EXISTING
|
||||
@@ -54,7 +54,7 @@ when defined(windows):
|
||||
else:
|
||||
CREATE_NEW
|
||||
else:
|
||||
proc getPosixFlags(mode: TFileMode): cint =
|
||||
proc getPosixFlags(mode: FileMode): cint =
|
||||
case mode
|
||||
of fmRead:
|
||||
result = O_RDONLY
|
||||
@@ -74,7 +74,7 @@ proc getFileSize(f: AsyncFile): int64 =
|
||||
var high: DWord
|
||||
let low = getFileSize(f.fd.THandle, addr high)
|
||||
if low == INVALID_FILE_SIZE:
|
||||
raiseOSError()
|
||||
raiseOSError(osLastError())
|
||||
return (high shl 32) or low
|
||||
|
||||
proc openAsync*(filename: string, mode = fmRead): AsyncFile =
|
||||
@@ -95,7 +95,7 @@ proc openAsync*(filename: string, mode = fmRead): AsyncFile =
|
||||
nil, creationDisposition, flags, 0).TAsyncFd
|
||||
|
||||
if result.fd.THandle == INVALID_HANDLE_VALUE:
|
||||
raiseOSError()
|
||||
raiseOSError(osLastError())
|
||||
|
||||
register(result.fd)
|
||||
|
||||
@@ -108,7 +108,7 @@ proc openAsync*(filename: string, mode = fmRead): AsyncFile =
|
||||
let perm = S_IRUSR or S_IWUSR or S_IRGRP or S_IWGRP or S_IROTH
|
||||
result.fd = open(filename, flags, perm).TAsyncFD
|
||||
if result.fd.cint == -1:
|
||||
raiseOSError()
|
||||
raiseOSError(osLastError())
|
||||
|
||||
register(result.fd)
|
||||
|
||||
@@ -185,7 +185,7 @@ proc read*(f: AsyncFile, size: int): Future[string] =
|
||||
if res < 0:
|
||||
let lastError = osLastError()
|
||||
if lastError.int32 != EAGAIN:
|
||||
retFuture.fail(newException(EOS, osErrorMsg(lastError)))
|
||||
retFuture.fail(newException(OSError, osErrorMsg(lastError)))
|
||||
else:
|
||||
result = false # We still want this callback to be called.
|
||||
elif res == 0:
|
||||
@@ -227,7 +227,7 @@ proc setFilePos*(f: AsyncFile, pos: int64) =
|
||||
when not defined(windows):
|
||||
let ret = lseek(f.fd.cint, pos, SEEK_SET)
|
||||
if ret == -1:
|
||||
raiseOSError()
|
||||
raiseOSError(osLastError())
|
||||
|
||||
proc readAll*(f: AsyncFile): Future[string] {.async.} =
|
||||
## Reads all data from the specified file.
|
||||
@@ -299,7 +299,7 @@ proc write*(f: AsyncFile, data: string): Future[void] =
|
||||
if res < 0:
|
||||
let lastError = osLastError()
|
||||
if lastError.int32 != EAGAIN:
|
||||
retFuture.fail(newException(EOS, osErrorMsg(lastError)))
|
||||
retFuture.fail(newException(OSError, osErrorMsg(lastError)))
|
||||
else:
|
||||
result = false # We still want this callback to be called.
|
||||
else:
|
||||
@@ -318,8 +318,8 @@ proc close*(f: AsyncFile) =
|
||||
## Closes the file specified.
|
||||
when defined(windows):
|
||||
if not closeHandle(f.fd.THandle).bool:
|
||||
raiseOSError()
|
||||
raiseOSError(osLastError())
|
||||
else:
|
||||
if close(f.fd.cint) == -1:
|
||||
raiseOSError()
|
||||
raiseOSError(osLastError())
|
||||
|
||||
|
||||
@@ -149,7 +149,7 @@ proc createDir*(ftp: AsyncFtpClient, dir: string, recursive = false){.async.} =
|
||||
assertReply reply, "257"
|
||||
|
||||
proc chmod*(ftp: AsyncFtpClient, path: string,
|
||||
permissions: set[TFilePermission]) {.async.} =
|
||||
permissions: set[FilePermission]) {.async.} =
|
||||
## Changes permission of ``path`` to ``permissions``.
|
||||
var userOctal = 0
|
||||
var groupOctal = 0
|
||||
@@ -188,7 +188,7 @@ proc retrText*(ftp: AsyncFtpClient, file: string): Future[string] {.async.} =
|
||||
|
||||
result = await ftp.getLines()
|
||||
|
||||
proc getFile(ftp: AsyncFtpClient, file: TFile, total: BiggestInt,
|
||||
proc getFile(ftp: AsyncFtpClient, file: File, total: BiggestInt,
|
||||
onProgressChanged: ProgressChangedProc) {.async.} =
|
||||
assert ftp.dsockConnected
|
||||
var progress = 0
|
||||
@@ -240,7 +240,7 @@ proc retrFile*(ftp: AsyncFtpClient, file, dest: string,
|
||||
|
||||
await getFile(ftp, destFile, fileSize, onProgressChanged)
|
||||
|
||||
proc doUpload(ftp: AsyncFtpClient, file: TFile,
|
||||
proc doUpload(ftp: AsyncFtpClient, file: File,
|
||||
onProgressChanged: ProgressChangedProc) {.async.} =
|
||||
assert ftp.dsockConnected
|
||||
|
||||
|
||||
@@ -675,7 +675,7 @@ when isMainModule:
|
||||
echo(data)
|
||||
echo("Finished reading! " & $no)
|
||||
|
||||
proc testAccept(s: AsyncSocket, disp: PDispatcher, no: int) =
|
||||
proc testAccept(s: AsyncSocket, disp: Dispatcher, no: int) =
|
||||
echo("Accepting client! " & $no)
|
||||
var client: AsyncSocket
|
||||
new(client)
|
||||
@@ -691,7 +691,7 @@ when isMainModule:
|
||||
var d = newDispatcher()
|
||||
|
||||
var s = asyncSocket()
|
||||
s.connect("amber.tenthbit.net", TPort(6667))
|
||||
s.connect("amber.tenthbit.net", Port(6667))
|
||||
s.handleConnect =
|
||||
proc (s: AsyncSocket) =
|
||||
testConnect(s, 1)
|
||||
@@ -704,7 +704,7 @@ when isMainModule:
|
||||
server.handleAccept =
|
||||
proc (s: AsyncSocket) =
|
||||
testAccept(s, d, 78)
|
||||
server.bindAddr(TPort(5555))
|
||||
server.bindAddr(Port(5555))
|
||||
server.listen()
|
||||
d.register(server)
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ proc openDefaultBrowser*(url: string) =
|
||||
for b in getEnv("BROWSER").string.split(PathSep):
|
||||
try:
|
||||
# we use ``startProcess`` here because we don't want to block!
|
||||
discard startProcess(command=b, args=[url], options={poUseShell})
|
||||
discard startProcess(command=b, args=[url], options={poUsePath})
|
||||
return
|
||||
except OSError:
|
||||
discard
|
||||
|
||||
@@ -29,7 +29,7 @@ type
|
||||
FSMonitorObj = object of RootObj
|
||||
fd: cint
|
||||
handleEvent: proc (m: FSMonitor, ev: MonitorEvent) {.closure.}
|
||||
targets: TTable[cint, string]
|
||||
targets: Table[cint, string]
|
||||
|
||||
MonitorEventType* = enum ## Monitor event type
|
||||
MonitorAccess, ## File was accessed.
|
||||
@@ -64,7 +64,7 @@ type
|
||||
const
|
||||
MaxEvents = 100
|
||||
|
||||
proc newMonitor*(): PFSMonitor =
|
||||
proc newMonitor*(): FSMonitor =
|
||||
## Creates a new file system monitor.
|
||||
new(result)
|
||||
result.targets = initTable[cint, string]()
|
||||
@@ -72,7 +72,7 @@ proc newMonitor*(): PFSMonitor =
|
||||
if result.fd < 0:
|
||||
raiseOSError(osLastError())
|
||||
|
||||
proc add*(monitor: PFSMonitor, target: string,
|
||||
proc add*(monitor: FSMonitor, target: string,
|
||||
filters = {MonitorAll}): cint {.discardable.} =
|
||||
## Adds ``target`` which may be a directory or a file to the list of
|
||||
## watched paths of ``monitor``.
|
||||
@@ -99,14 +99,14 @@ proc add*(monitor: PFSMonitor, target: string,
|
||||
raiseOSError(osLastError())
|
||||
monitor.targets.add(result, target)
|
||||
|
||||
proc del*(monitor: PFSMonitor, wd: cint) =
|
||||
proc del*(monitor: FSMonitor, wd: cint) =
|
||||
## Removes watched directory or file as specified by ``wd`` from ``monitor``.
|
||||
##
|
||||
## If ``wd`` is not a part of ``monitor`` an EOS error is raised.
|
||||
if inotifyRmWatch(monitor.fd, wd) < 0:
|
||||
raiseOSError(osLastError())
|
||||
|
||||
proc getEvent(m: PFSMonitor, fd: cint): seq[TMonitorEvent] =
|
||||
proc getEvent(m: FSMonitor, fd: cint): seq[MonitorEvent] =
|
||||
result = @[]
|
||||
let size = (sizeof(TINotifyEvent)+2000)*MaxEvents
|
||||
var buffer = newString(size)
|
||||
@@ -118,7 +118,7 @@ proc getEvent(m: PFSMonitor, fd: cint): seq[TMonitorEvent] =
|
||||
var i = 0
|
||||
while i < le:
|
||||
var event = cast[ptr TINotifyEvent](addr(buffer[i]))
|
||||
var mev: TMonitorEvent
|
||||
var mev: MonitorEvent
|
||||
mev.wd = event.wd
|
||||
if event.len.int != 0:
|
||||
let cstr = event.name.addr.cstring
|
||||
@@ -137,7 +137,7 @@ proc getEvent(m: PFSMonitor, fd: cint): seq[TMonitorEvent] =
|
||||
# Find the MovedFrom event.
|
||||
mev.oldPath = movedFrom[event.cookie.cint].old
|
||||
mev.newPath = "" # Set later
|
||||
# Delete it from the TTable
|
||||
# Delete it from the Table
|
||||
movedFrom.del(event.cookie.cint)
|
||||
elif (event.mask.int and IN_ACCESS) != 0: mev.kind = MonitorAccess
|
||||
elif (event.mask.int and IN_ATTRIB) != 0: mev.kind = MonitorAttrib
|
||||
@@ -164,26 +164,26 @@ proc getEvent(m: PFSMonitor, fd: cint): seq[TMonitorEvent] =
|
||||
# If movedFrom events have not been matched with a moveTo. File has
|
||||
# been moved to an unwatched location, emit a MonitorDelete.
|
||||
for cookie, t in pairs(movedFrom):
|
||||
var mev: TMonitorEvent
|
||||
var mev: MonitorEvent
|
||||
mev.kind = MonitorDelete
|
||||
mev.wd = t.wd
|
||||
mev.name = t.old
|
||||
result.add(mev)
|
||||
|
||||
proc FSMonitorRead(h: PObject) =
|
||||
var events = PFSMonitor(h).getEvent(PFSMonitor(h).fd)
|
||||
#var newEv: TMonitorEvent
|
||||
proc FSMonitorRead(h: RootRef) =
|
||||
var events = FSMonitor(h).getEvent(FSMonitor(h).fd)
|
||||
#var newEv: MonitorEvent
|
||||
for ev in events:
|
||||
var target = PFSMonitor(h).targets[ev.wd]
|
||||
var target = FSMonitor(h).targets[ev.wd]
|
||||
var newEv = ev
|
||||
if newEv.kind == MonitorMoved:
|
||||
newEv.oldPath = target / newEv.oldPath
|
||||
newEv.newPath = target / newEv.name
|
||||
else:
|
||||
newEv.fullName = target / newEv.name
|
||||
PFSMonitor(h).handleEvent(PFSMonitor(h), newEv)
|
||||
FSMonitor(h).handleEvent(FSMonitor(h), newEv)
|
||||
|
||||
proc toDelegate(m: PFSMonitor): PDelegate =
|
||||
proc toDelegate(m: FSMonitor): Delegate =
|
||||
result = newDelegate()
|
||||
result.deleVal = m
|
||||
result.fd = (type(result.fd))(m.fd)
|
||||
@@ -191,8 +191,8 @@ proc toDelegate(m: PFSMonitor): PDelegate =
|
||||
result.handleRead = FSMonitorRead
|
||||
result.open = true
|
||||
|
||||
proc register*(d: PDispatcher, monitor: PFSMonitor,
|
||||
handleEvent: proc (m: PFSMonitor, ev: TMonitorEvent) {.closure.}) =
|
||||
proc register*(d: Dispatcher, monitor: FSMonitor,
|
||||
handleEvent: proc (m: FSMonitor, ev: MonitorEvent) {.closure.}) =
|
||||
## Registers ``monitor`` with dispatcher ``d``.
|
||||
monitor.handleEvent = handleEvent
|
||||
var deleg = toDelegate(monitor)
|
||||
@@ -204,7 +204,7 @@ when isMainModule:
|
||||
var monitor = newMonitor()
|
||||
echo monitor.add("/home/dom/inotifytests/")
|
||||
disp.register(monitor,
|
||||
proc (m: PFSMonitor, ev: TMonitorEvent) =
|
||||
proc (m: FSMonitor, ev: MonitorEvent) =
|
||||
echo("Got event: ", ev.kind)
|
||||
if ev.kind == MonitorMoved:
|
||||
echo("From ", ev.oldPath, " to ", ev.newPath)
|
||||
|
||||
@@ -107,7 +107,7 @@ type
|
||||
EInvalidReply: ReplyError, EFTP: FTPError
|
||||
].}
|
||||
|
||||
proc ftpClient*(address: string, port = TPort(21),
|
||||
proc ftpClient*(address: string, port = Port(21),
|
||||
user, pass = ""): FtpClient =
|
||||
## Create a ``FtpClient`` object.
|
||||
new(result)
|
||||
@@ -120,10 +120,10 @@ proc ftpClient*(address: string, port = TPort(21),
|
||||
result.csock = socket()
|
||||
if result.csock == invalidSocket: raiseOSError(osLastError())
|
||||
|
||||
template blockingOperation(sock: TSocket, body: stmt) {.immediate.} =
|
||||
template blockingOperation(sock: Socket, body: stmt) {.immediate.} =
|
||||
body
|
||||
|
||||
template blockingOperation(sock: asyncio.PAsyncSocket, body: stmt) {.immediate.} =
|
||||
template blockingOperation(sock: asyncio.AsyncSocket, body: stmt) {.immediate.} =
|
||||
sock.setBlocking(true)
|
||||
body
|
||||
sock.setBlocking(false)
|
||||
@@ -145,14 +145,14 @@ proc send*[T](ftp: FtpBase[T], m: string): TaintedString =
|
||||
|
||||
proc assertReply(received: TaintedString, expected: string) =
|
||||
if not received.string.startsWith(expected):
|
||||
raise newException(EInvalidReply,
|
||||
raise newException(ReplyError,
|
||||
"Expected reply '$1' got: $2" % [
|
||||
expected, received.string])
|
||||
|
||||
proc assertReply(received: TaintedString, expected: varargs[string]) =
|
||||
for i in items(expected):
|
||||
if received.string.startsWith(i): return
|
||||
raise newException(EInvalidReply,
|
||||
raise newException(ReplyError,
|
||||
"Expected reply '$1' got: $2" %
|
||||
[expected.join("' or '"), received.string])
|
||||
|
||||
@@ -161,7 +161,7 @@ proc createJob[T](ftp: FtpBase[T],
|
||||
nimcall,gcsafe.},
|
||||
cmd: FTPJobType) =
|
||||
if ftp.jobInProgress:
|
||||
raise newException(EFTP, "Unable to do two jobs at once.")
|
||||
raise newException(FTPError, "Unable to do two jobs at once.")
|
||||
ftp.jobInProgress = true
|
||||
new(ftp.job)
|
||||
ftp.job.prc = prc
|
||||
@@ -182,11 +182,11 @@ proc deleteJob[T](ftp: FtpBase[T]) =
|
||||
ftp.job.file.close()
|
||||
ftp.dsock.close()
|
||||
|
||||
proc handleTask(s: PAsyncSocket, ftp: PAsyncFTPClient) =
|
||||
proc handleTask(s: AsyncSocket, ftp: AsyncFTPClient) =
|
||||
if ftp.jobInProgress:
|
||||
if ftp.job.typ in {JRetr, JStore}:
|
||||
if epochTime() - ftp.job.lastProgressReport >= 1.0:
|
||||
var r: TFTPEvent
|
||||
var r: FTPEvent
|
||||
ftp.job.lastProgressReport = epochTime()
|
||||
r.typ = EvTransferProgress
|
||||
r.bytesTotal = ftp.job.total
|
||||
@@ -195,22 +195,22 @@ proc handleTask(s: PAsyncSocket, ftp: PAsyncFTPClient) =
|
||||
r.filename = ftp.job.filename
|
||||
r.currentJob = ftp.job.typ
|
||||
ftp.job.oneSecond = 0
|
||||
ftp.handleEvent(PAsyncFTPClient(ftp), r)
|
||||
ftp.handleEvent(ftp, r)
|
||||
|
||||
proc handleWrite(s: PAsyncSocket, ftp: PAsyncFTPClient) =
|
||||
proc handleWrite(s: AsyncSocket, ftp: AsyncFTPClient) =
|
||||
if ftp.jobInProgress:
|
||||
if ftp.job.typ == JStore:
|
||||
assert (not ftp.job.prc(ftp, true))
|
||||
|
||||
proc handleConnect(s: PAsyncSocket, ftp: PAsyncFTPClient) =
|
||||
proc handleConnect(s: AsyncSocket, ftp: AsyncFTPClient) =
|
||||
ftp.dsockConnected = true
|
||||
assert(ftp.jobInProgress)
|
||||
if ftp.job.typ == JStore:
|
||||
s.setHandleWrite(proc (s: PAsyncSocket) = handleWrite(s, ftp))
|
||||
s.setHandleWrite(proc (s: AsyncSocket) = handleWrite(s, ftp))
|
||||
else:
|
||||
s.delHandleWrite()
|
||||
|
||||
proc handleRead(s: PAsyncSocket, ftp: PAsyncFTPClient) =
|
||||
proc handleRead(s: AsyncSocket, ftp: AsyncFTPClient) =
|
||||
assert ftp.jobInProgress
|
||||
assert ftp.job.typ != JStore
|
||||
# This can never return true, because it shouldn't check for code
|
||||
@@ -219,19 +219,19 @@ proc handleRead(s: PAsyncSocket, ftp: PAsyncFTPClient) =
|
||||
|
||||
proc pasv[T](ftp: FtpBase[T]) =
|
||||
## Negotiate a data connection.
|
||||
when T is TSocket:
|
||||
when T is Socket:
|
||||
ftp.dsock = socket()
|
||||
if ftp.dsock == invalidSocket: raiseOSError(osLastError())
|
||||
elif T is PAsyncSocket:
|
||||
elif T is AsyncSocket:
|
||||
ftp.dsock = asyncSocket()
|
||||
ftp.dsock.handleRead =
|
||||
proc (s: PAsyncSocket) =
|
||||
proc (s: AsyncSocket) =
|
||||
handleRead(s, ftp)
|
||||
ftp.dsock.handleConnect =
|
||||
proc (s: PAsyncSocket) =
|
||||
proc (s: AsyncSocket) =
|
||||
handleConnect(s, ftp)
|
||||
ftp.dsock.handleTask =
|
||||
proc (s: PAsyncSocket) =
|
||||
proc (s: AsyncSocket) =
|
||||
handleTask(s, ftp)
|
||||
ftp.disp.register(ftp.dsock)
|
||||
else:
|
||||
@@ -244,8 +244,8 @@ proc pasv[T](ftp: FtpBase[T]) =
|
||||
var ip = nums[0.. -3]
|
||||
var port = nums[-2.. -1]
|
||||
var properPort = port[0].parseInt()*256+port[1].parseInt()
|
||||
ftp.dsock.connect(ip.join("."), TPort(properPort.toU16))
|
||||
when T is PAsyncSocket:
|
||||
ftp.dsock.connect(ip.join("."), Port(properPort.toU16))
|
||||
when T is AsyncSocket:
|
||||
ftp.dsockConnected = false
|
||||
else:
|
||||
ftp.dsockConnected = true
|
||||
@@ -255,10 +255,10 @@ proc normalizePathSep(path: string): string =
|
||||
|
||||
proc connect*[T](ftp: FtpBase[T]) =
|
||||
## Connect to the FTP server specified by ``ftp``.
|
||||
when T is PAsyncSocket:
|
||||
when T is AsyncSocket:
|
||||
blockingOperation(ftp.csock):
|
||||
ftp.csock.connect(ftp.address, ftp.port)
|
||||
elif T is TSocket:
|
||||
elif T is Socket:
|
||||
ftp.csock.connect(ftp.address, ftp.port)
|
||||
else:
|
||||
{.fatal: "Incorrect socket instantiation".}
|
||||
@@ -292,13 +292,13 @@ proc getLines[T](ftp: FtpBase[T], async: bool = false): bool =
|
||||
## It doesn't if `async` is true, because it doesn't check for 226 then.
|
||||
if ftp.dsockConnected:
|
||||
var r = TaintedString""
|
||||
when T is PAsyncSocket:
|
||||
when T is AsyncSocket:
|
||||
if ftp.asyncDSock.readLine(r):
|
||||
if r.string == "":
|
||||
ftp.dsockConnected = false
|
||||
else:
|
||||
ftp.job.lines.add(r.string & "\n")
|
||||
elif T is TSocket:
|
||||
elif T is Socket:
|
||||
assert(not async)
|
||||
ftp.dsock.readLine(r)
|
||||
if r.string == "":
|
||||
@@ -309,7 +309,7 @@ proc getLines[T](ftp: FtpBase[T], async: bool = false): bool =
|
||||
{.fatal: "Incorrect socket instantiation".}
|
||||
|
||||
if not async:
|
||||
var readSocks: seq[TSocket] = @[ftp.csock]
|
||||
var readSocks: seq[Socket] = @[ftp.csock]
|
||||
# This is only needed here. Asyncio gets this socket...
|
||||
blockingOperation(ftp.csock):
|
||||
if readSocks.select(1) != 0 and ftp.csock in readSocks:
|
||||
@@ -372,7 +372,7 @@ proc createDir*[T](ftp: FtpBase[T], dir: string, recursive: bool = false) =
|
||||
assertReply reply, "257"
|
||||
|
||||
proc chmod*[T](ftp: FtpBase[T], path: string,
|
||||
permissions: set[TFilePermission]) =
|
||||
permissions: set[FilePermission]) =
|
||||
## Changes permission of ``path`` to ``permissions``.
|
||||
var userOctal = 0
|
||||
var groupOctal = 0
|
||||
@@ -431,8 +431,8 @@ proc getFile[T](ftp: FtpBase[T], async = false): bool =
|
||||
var bytesRead = 0
|
||||
var returned = false
|
||||
if async:
|
||||
when T is TSocket:
|
||||
raise newException(EFTP, "FTPClient must be async.")
|
||||
when T is Socket:
|
||||
raise newException(FTPError, "FTPClient must be async.")
|
||||
else:
|
||||
bytesRead = ftp.dsock.recvAsync(r, BufferSize)
|
||||
returned = bytesRead != -1
|
||||
@@ -447,9 +447,9 @@ proc getFile[T](ftp: FtpBase[T], async = false): bool =
|
||||
elif returned and r2 == "":
|
||||
ftp.dsockConnected = false
|
||||
|
||||
when T is TSocket:
|
||||
when T is Socket:
|
||||
if not async:
|
||||
var readSocks: seq[TSocket] = @[ftp.csock]
|
||||
var readSocks: seq[Socket] = @[ftp.csock]
|
||||
blockingOperation(ftp.csock):
|
||||
if readSocks.select(1) != 0 and ftp.csock in readSocks:
|
||||
assertReply ftp.expectReply(), "226"
|
||||
@@ -467,10 +467,10 @@ proc retrFile*[T](ftp: FtpBase[T], file, dest: string, async = false) =
|
||||
var reply = ftp.send("RETR " & file.normalizePathSep)
|
||||
assertReply reply, ["125", "150"]
|
||||
if {'(', ')'} notin reply.string:
|
||||
raise newException(EInvalidReply, "Reply has no file size.")
|
||||
raise newException(ReplyError, "Reply has no file size.")
|
||||
var fileSize: BiggestInt
|
||||
if reply.string.captureBetween('(', ')').parseBiggestInt(fileSize) == 0:
|
||||
raise newException(EInvalidReply, "Reply has no file size.")
|
||||
raise newException(ReplyError, "Reply has no file size.")
|
||||
|
||||
ftp.job.total = fileSize
|
||||
ftp.job.lastProgressReport = epochTime()
|
||||
@@ -545,10 +545,10 @@ proc close*[T](ftp: FtpBase[T]) =
|
||||
ftp.csock.close()
|
||||
ftp.dsock.close()
|
||||
|
||||
proc csockHandleRead(s: PAsyncSocket, ftp: PAsyncFTPClient) =
|
||||
proc csockHandleRead(s: AsyncSocket, ftp: AsyncFTPClient) =
|
||||
if ftp.jobInProgress:
|
||||
assertReply ftp.expectReply(), "226" # Make sure the transfer completed.
|
||||
var r: TFTPEvent
|
||||
var r: FTPEvent
|
||||
case ftp.job.typ
|
||||
of JRetrText:
|
||||
r.typ = EvLines
|
||||
@@ -557,21 +557,21 @@ proc csockHandleRead(s: PAsyncSocket, ftp: PAsyncFTPClient) =
|
||||
r.typ = EvRetr
|
||||
r.filename = ftp.job.filename
|
||||
if ftp.job.progress != ftp.job.total:
|
||||
raise newException(EFTP, "Didn't download full file.")
|
||||
raise newException(FTPError, "Didn't download full file.")
|
||||
of JStore:
|
||||
r.typ = EvStore
|
||||
r.filename = ftp.job.filename
|
||||
if ftp.job.progress != ftp.job.total:
|
||||
raise newException(EFTP, "Didn't upload full file.")
|
||||
raise newException(FTPError, "Didn't upload full file.")
|
||||
ftp.deleteJob()
|
||||
|
||||
ftp.handleEvent(ftp, r)
|
||||
|
||||
proc asyncFTPClient*(address: string, port = TPort(21),
|
||||
proc asyncFTPClient*(address: string, port = Port(21),
|
||||
user, pass = "",
|
||||
handleEvent: proc (ftp: PAsyncFTPClient, ev: TFTPEvent) {.closure,gcsafe.} =
|
||||
(proc (ftp: PAsyncFTPClient, ev: TFTPEvent) = discard)): PAsyncFTPClient =
|
||||
## Create a ``PAsyncFTPClient`` object.
|
||||
handleEvent: proc (ftp: AsyncFTPClient, ev: FTPEvent) {.closure,gcsafe.} =
|
||||
(proc (ftp: AsyncFTPClient, ev: FTPEvent) = discard)): AsyncFTPClient =
|
||||
## Create a ``AsyncFTPClient`` object.
|
||||
##
|
||||
## Use this if you want to use asyncio's dispatcher.
|
||||
var dres: AsyncFtpClient
|
||||
@@ -588,7 +588,7 @@ proc asyncFTPClient*(address: string, port = TPort(21),
|
||||
csockHandleRead(s, dres)
|
||||
result = dres
|
||||
|
||||
proc register*(d: PDispatcher, ftp: PAsyncFTPClient): PDelegate {.discardable.} =
|
||||
proc register*(d: Dispatcher, ftp: AsyncFTPClient): Delegate {.discardable.} =
|
||||
## Registers ``ftp`` with dispatcher ``d``.
|
||||
ftp.disp = d
|
||||
return ftp.disp.register(ftp.csock)
|
||||
|
||||
@@ -260,7 +260,7 @@ proc execProcesses*(cmds: openArray[string],
|
||||
for i in 0..m-1:
|
||||
if beforeRunEvent != nil:
|
||||
beforeRunEvent(i)
|
||||
q[i] = startCmd(cmds[i], options=options)
|
||||
q[i] = startProcess(cmds[i], options=options + {poEvalCommand})
|
||||
when defined(noBusyWaiting):
|
||||
var r = 0
|
||||
for i in m..high(cmds):
|
||||
@@ -275,7 +275,7 @@ proc execProcesses*(cmds: openArray[string],
|
||||
if q[r] != nil: close(q[r])
|
||||
if beforeRunEvent != nil:
|
||||
beforeRunEvent(i)
|
||||
q[r] = startCmd(cmds[i], options=options)
|
||||
q[r] = startProcess(cmds[i], options=options + {poEvalCommand})
|
||||
r = (r + 1) mod n
|
||||
else:
|
||||
var i = m
|
||||
@@ -288,7 +288,7 @@ proc execProcesses*(cmds: openArray[string],
|
||||
if q[r] != nil: close(q[r])
|
||||
if beforeRunEvent != nil:
|
||||
beforeRunEvent(i)
|
||||
q[r] = startCmd(cmds[i], options=options)
|
||||
q[r] = startProcess(cmds[i], options=options + {poEvalCommand})
|
||||
inc(i)
|
||||
if i > high(cmds): break
|
||||
for j in 0..m-1:
|
||||
@@ -298,7 +298,7 @@ proc execProcesses*(cmds: openArray[string],
|
||||
for i in 0..high(cmds):
|
||||
if beforeRunEvent != nil:
|
||||
beforeRunEvent(i)
|
||||
var p = startCmd(cmds[i], options=options)
|
||||
var p = startProcess(cmds[i], options=options + {poEvalCommand})
|
||||
result = max(waitForExit(p), result)
|
||||
close(p)
|
||||
|
||||
@@ -644,14 +644,14 @@ elif not defined(useNimRtl):
|
||||
var pid: TPid
|
||||
|
||||
var sysArgs = allocCStringArray(sysArgsRaw)
|
||||
finally: deallocCStringArray(sysArgs)
|
||||
defer: deallocCStringArray(sysArgs)
|
||||
|
||||
var sysEnv = if env == nil:
|
||||
envToCStringArray()
|
||||
else:
|
||||
envToCStringArray(env)
|
||||
|
||||
finally: deallocCStringArray(sysEnv)
|
||||
defer: deallocCStringArray(sysEnv)
|
||||
|
||||
var data: TStartProcessData
|
||||
data.sysCommand = sysCommand
|
||||
@@ -748,7 +748,7 @@ elif not defined(useNimRtl):
|
||||
if pipe(data.pErrorPipe) != 0:
|
||||
raiseOSError(osLastError())
|
||||
|
||||
finally:
|
||||
defer:
|
||||
discard close(data.pErrorPipe[readIdx])
|
||||
|
||||
var pid: TPid
|
||||
@@ -956,7 +956,7 @@ proc execCmdEx*(command: string, options: set[ProcessOption] = {
|
||||
exitCode: int] {.tags: [ExecIOEffect, ReadIOEffect], gcsafe.} =
|
||||
## a convenience proc that runs the `command`, grabs all its output and
|
||||
## exit code and returns both.
|
||||
var p = startCmd(command, options)
|
||||
var p = startProcess(command, options=options + {poEvalCommand})
|
||||
var outp = outputStream(p)
|
||||
result = (TaintedString"", -1)
|
||||
var line = newStringOfCap(120).TaintedString
|
||||
|
||||
@@ -353,11 +353,11 @@ when isMainModule:
|
||||
|
||||
proc `%`(formatstr: string, a: openarray[string]): string =
|
||||
result = newStringOfCap(formatstr.len + a.len shl 4)
|
||||
addf(result, formatstr.TSubex, a)
|
||||
addf(result, formatstr.Subex, a)
|
||||
|
||||
proc `%`(formatstr: string, a: string): string =
|
||||
result = newStringOfCap(formatstr.len + a.len)
|
||||
addf(result, formatstr.TSubex, [a])
|
||||
addf(result, formatstr.Subex, [a])
|
||||
|
||||
|
||||
doAssert "$# $3 $# $#" % ["a", "b", "c"] == "a c b c"
|
||||
|
||||
@@ -20,6 +20,7 @@ type
|
||||
|
||||
{.deprecated: [TUrl: Url, TUri: Uri].}
|
||||
|
||||
{.push warning[deprecated]: off.}
|
||||
proc `$`*(url: Url): string {.deprecated.} =
|
||||
## **Deprecated since 0.9.6**: Use ``Uri`` instead.
|
||||
return string(url)
|
||||
@@ -44,6 +45,7 @@ proc add*(url: var Url, a: Url) {.deprecated.} =
|
||||
##
|
||||
## **Deprecated since 0.9.6**: Use ``Uri`` instead.
|
||||
url = url / a
|
||||
{.pop.}
|
||||
|
||||
proc parseAuthority(authority: string, result: var Uri) =
|
||||
var i = 0
|
||||
|
||||
@@ -64,7 +64,7 @@ proc node_move*(n: ptr TNode, oldlist: ptr TList, newlist: ptr TList){.
|
||||
cdecl, importc: "node_move", dynlib: clarodll.}
|
||||
|
||||
type
|
||||
TClaroObj*{.pure.} = object
|
||||
TClaroObj*{.pure, inheritable.} = object
|
||||
typ*: array[0..64 - 1, char]
|
||||
destroy_pending*: cint
|
||||
event_handlers*: TList
|
||||
@@ -86,7 +86,7 @@ type
|
||||
TEventHandler*{.pure.} = object
|
||||
typ*: array[0..32 - 1, char]
|
||||
data*: pointer
|
||||
func*: TEventFunc # the function that handles this event
|
||||
fun*: TEventFunc # the function that handles this event
|
||||
|
||||
|
||||
# #define event_handler(n) void n ( TClaroObj *object, event_t *event )
|
||||
@@ -121,10 +121,10 @@ proc object_set_parent*(obj: ptr TClaroObj, parent: ptr TClaroObj){.cdecl,
|
||||
# event functions
|
||||
|
||||
proc object_addhandler*(obj: ptr TClaroObj, event: cstring,
|
||||
func: TEventFunc){.cdecl,
|
||||
fun: TEventFunc){.cdecl,
|
||||
importc: "object_addhandler", dynlib: clarodll.}
|
||||
proc object_addhandler_interface*(obj: ptr TClaroObj, event: cstring,
|
||||
func: TEventFunc, data: pointer){.cdecl,
|
||||
fun: TEventFunc, data: pointer){.cdecl,
|
||||
importc: "object_addhandler_interface", dynlib: clarodll.}
|
||||
proc event_send*(obj: ptr TClaroObj, event: cstring, fmt: cstring): cint{.
|
||||
varargs, cdecl, importc: "event_send", dynlib: clarodll.}
|
||||
@@ -258,7 +258,7 @@ proc image_load_inline_png*(parent: ptr TClaroObj, data: cstring,
|
||||
## len size of data
|
||||
|
||||
when true:
|
||||
nil
|
||||
discard
|
||||
else:
|
||||
# status icons are not supported on all platforms yet:
|
||||
type
|
||||
@@ -682,7 +682,7 @@ const
|
||||
type
|
||||
TCanvas*{.pure.} = object of TWidget
|
||||
surface*: cairo.PSurface
|
||||
cr*: Cairo.PContext
|
||||
cr*: cairo.PContext
|
||||
surfdata*: pointer
|
||||
fontdata*: pointer
|
||||
font_height*: cint
|
||||
@@ -854,7 +854,7 @@ proc canvas_cairo_buffered_text_display_count*(widget: ptr TCanvas,
|
||||
text: cstring, width: cint): cint{.cdecl,
|
||||
importc: "canvas_cairo_buffered_text_display_count",
|
||||
dynlib: clarodll.}
|
||||
proc canvas_get_cairo_context*(widget: ptr TCanvas): Cairo.PContext {.cdecl,
|
||||
proc canvas_get_cairo_context*(widget: ptr TCanvas): cairo.PContext {.cdecl,
|
||||
importc: "canvas_get_cairo_context", dynlib: clarodll.}
|
||||
|
||||
type
|
||||
|
||||
@@ -30,9 +30,9 @@ type
|
||||
CheckProc* = proc (handle: PCheck, status: cint) {.cdecl.}
|
||||
IdleProc* = proc (handle: PIdle, status: cint) {.cdecl.}
|
||||
|
||||
PSockAddr* = ptr TSockAddr
|
||||
PSockAddr* = ptr SockAddr
|
||||
|
||||
GetAddrInfoProc* = proc (handle: PGetAddrInfo, status: cint, res: ptr TAddrInfo)
|
||||
GetAddrInfoProc* = proc (handle: PGetAddrInfo, status: cint, res: ptr AddrInfo)
|
||||
|
||||
ExitProc* = proc (a2: PProcess, exit_status: cint, term_signal: cint)
|
||||
FsProc* = proc (req: PFS)
|
||||
@@ -210,7 +210,7 @@ type
|
||||
cunsigned = int
|
||||
|
||||
UdpSendProc* = proc (req: PUdpSend, status: cint)
|
||||
UdpRecvProc* = proc (handle: PUdp, nread: cssize, buf: TBuf, adr: ptr TSockAddr, flags: cunsigned)
|
||||
UdpRecvProc* = proc (handle: PUdp, nread: cssize, buf: TBuf, adr: ptr SockAddr, flags: cunsigned)
|
||||
|
||||
TUdp* {.pure, final, importc: "uv_udp_t", header: "uv.h".} = object
|
||||
loop* {.importc: "loop".}: PLoop
|
||||
@@ -366,7 +366,7 @@ type
|
||||
tcp_port* {.importc: "tcp_port".}: TPort
|
||||
socket_send_buffer_size* {.importc: "socket_send_buffer_size".}: int
|
||||
socket_recv_buffer_size* {.importc: "socket_receive_buffer_size".}: int
|
||||
servers* {.importc: "servers".}: ptr TInAddr
|
||||
servers* {.importc: "servers".}: ptr InAddr
|
||||
nservers* {.importc: "nservers".}: int
|
||||
domains* {.importc: "domains".}: ptr cstring
|
||||
ndomains* {.importc: "ndomains".}: int
|
||||
@@ -450,19 +450,19 @@ proc write*(req: PWrite, handle: PStream, bufs: ptr TBuf, bufcnt: cint, send_han
|
||||
proc tcp_init*(a2: PLoop, handle: PTcp): cint{.
|
||||
importc: "uv_tcp_init", header: "uv.h".}
|
||||
|
||||
proc tcp_bind*(handle: PTcp, a3: TSockAddrIn): cint{.
|
||||
proc tcp_bind*(handle: PTcp, a3: SockAddrIn): cint{.
|
||||
importc: "uv_tcp_bind", header: "uv.h".}
|
||||
|
||||
proc tcp_bind6*(handle: PTcp, a3: TSockAddrIn6): cint{.
|
||||
importc: "uv_tcp_bind6", header: "uv.h".}
|
||||
|
||||
proc tcp_getsockname*(handle: PTcp, name: ptr TSockAddr, namelen: var cint): cint{.
|
||||
proc tcp_getsockname*(handle: PTcp, name: ptr SockAddr, namelen: var cint): cint{.
|
||||
importc: "uv_tcp_getsockname", header: "uv.h".}
|
||||
|
||||
proc tcp_getpeername*(handle: PTcp, name: ptr TSockAddr, namelen: var cint): cint{.
|
||||
proc tcp_getpeername*(handle: PTcp, name: ptr SockAddr, namelen: var cint): cint{.
|
||||
importc: "uv_tcp_getpeername", header: "uv.h".}
|
||||
|
||||
proc tcp_connect*(req: PConnect, handle: PTcp, address: TSockAddrIn, cb: ConnectProc): cint{.
|
||||
proc tcp_connect*(req: PConnect, handle: PTcp, address: SockAddrIn, cb: ConnectProc): cint{.
|
||||
importc: "uv_tcp_connect", header: "uv.h".}
|
||||
|
||||
proc tcp_connect6*(req: PConnect, handle: PTcp, address: TSockAddrIn6, cb: ConnectProc): cint{.
|
||||
@@ -471,16 +471,16 @@ proc tcp_connect6*(req: PConnect, handle: PTcp, address: TSockAddrIn6, cb: Conne
|
||||
proc udp_init*(a2: PLoop, handle: PUdp): cint{.
|
||||
importc: "uv_udp_init", header: "uv.h".}
|
||||
|
||||
proc udp_bind*(handle: PUdp, adr: TSockAddrIn, flags: cunsigned): cint{.
|
||||
proc udp_bind*(handle: PUdp, adr: SockAddrIn, flags: cunsigned): cint{.
|
||||
importc: "uv_udp_bind", header: "uv.h".}
|
||||
|
||||
proc udp_bind6*(handle: PUdp, adr: TSockAddrIn6, flags: cunsigned): cint{.
|
||||
importc: "uv_udp_bind6", header: "uv.h".}
|
||||
|
||||
proc udp_getsockname*(handle: PUdp, name: ptr TSockAddr, namelen: var cint): cint{.
|
||||
proc udp_getsockname*(handle: PUdp, name: ptr SockAddr, namelen: var cint): cint{.
|
||||
importc: "uv_udp_getsockname", header: "uv.h".}
|
||||
|
||||
proc udp_send*(req: PUdpSend, handle: PUdp, bufs: ptr TBuf, bufcnt: cint, adr: TSockAddrIn, send_cb: UdpSendProc): cint{.
|
||||
proc udp_send*(req: PUdpSend, handle: PUdp, bufs: ptr TBuf, bufcnt: cint, adr: SockAddrIn, send_cb: UdpSendProc): cint{.
|
||||
importc: "uv_udp_send", header: "uv.h".}
|
||||
|
||||
proc udp_send6*(req: PUdpSend, handle: PUdp, bufs: ptr TBuf, bufcnt: cint, adr: TSockAddrIn6, send_cb: UdpSendProc): cint{.
|
||||
@@ -492,7 +492,7 @@ proc udp_recv_start*(handle: PUdp, alloc_cb: AllocProc, recv_cb: UdpRecvProc): c
|
||||
proc udp_recv_stop*(handle: PUdp): cint{.
|
||||
importc: "uv_udp_recv_stop", header: "uv.h".}
|
||||
|
||||
proc tty_init*(a2: PLoop, a3: pTTy, fd: TFile): cint{.
|
||||
proc tty_init*(a2: PLoop, a3: pTTy, fd: File): cint{.
|
||||
importc: "uv_tty_init", header: "uv.h".}
|
||||
|
||||
proc tty_set_mode*(a2: pTTy, mode: cint): cint{.
|
||||
@@ -504,13 +504,13 @@ proc tty_get_winsize*(a2: pTTy, width: var cint, height: var cint): cint{.
|
||||
proc tty_reset_mode*() {.
|
||||
importc: "uv_tty_reset_mode", header: "uv.h".}
|
||||
|
||||
proc guess_handle*(file: TFile): THandleType{.
|
||||
proc guess_handle*(file: File): THandleType{.
|
||||
importc: "uv_guess_handle", header: "uv.h".}
|
||||
|
||||
proc pipe_init*(a2: PLoop, handle: PPipe, ipc: int): cint{.
|
||||
importc: "uv_pipe_init", header: "uv.h".}
|
||||
|
||||
proc pipe_open*(a2: PPipe, file: TFile){.
|
||||
proc pipe_open*(a2: PPipe, file: File){.
|
||||
importc: "uv_pipe_open", header: "uv.h".}
|
||||
|
||||
proc pipe_bind*(handle: PPipe, name: cstring): cint{.
|
||||
@@ -576,10 +576,10 @@ proc ares_init_options*(a2: PLoop, channel: PAresChannel, options: PAresOptions,
|
||||
proc ares_destroy*(a2: PLoop, channel: PAresChannel){.
|
||||
importc: "uv_ares_destroy", header: "uv.h".}
|
||||
|
||||
proc getaddrinfo*(a2: PLoop, handle: PGetAddrInfo,getaddrinfo_cb: GetAddrInfoProc, node: cstring, service: cstring, hints: ptr TAddrInfo): cint{.
|
||||
proc getaddrinfo*(a2: PLoop, handle: PGetAddrInfo,getaddrinfo_cb: GetAddrInfoProc, node: cstring, service: cstring, hints: ptr AddrInfo): cint{.
|
||||
importc: "uv_getaddrinfo", header: "uv.h".}
|
||||
|
||||
proc freeaddrinfo*(ai: ptr TAddrInfo){.
|
||||
proc freeaddrinfo*(ai: ptr AddrInfo){.
|
||||
importc: "uv_freeaddrinfo", header: "uv.h".}
|
||||
|
||||
proc spawn*(a2: PLoop, a3: PProcess, options: TProcessOptions): cint{.
|
||||
@@ -594,19 +594,19 @@ proc queue_work*(loop: PLoop, req: PWork, work_cb: WorkProc, after_work_cb: Afte
|
||||
proc req_cleanup*(req: PFS){.
|
||||
importc: "uv_fs_req_cleanup", header: "uv.h".}
|
||||
|
||||
proc close*(loop: PLoop, req: PFS, file: TFile, cb: FsProc): cint{.
|
||||
proc close*(loop: PLoop, req: PFS, file: File, cb: FsProc): cint{.
|
||||
importc: "uv_fs_close", header: "uv.h".}
|
||||
|
||||
proc open*(loop: PLoop, req: PFS, path: cstring, flags: cint, mode: cint, cb: FsProc): cint{.
|
||||
importc: "uv_fs_open", header: "uv.h".}
|
||||
|
||||
proc read*(loop: PLoop, req: PFS, file: TFile, buf: pointer, length: csize, offset: coff, cb: FsProc): cint{.
|
||||
proc read*(loop: PLoop, req: PFS, file: File, buf: pointer, length: csize, offset: coff, cb: FsProc): cint{.
|
||||
importc: "uv_fs_read", header: "uv.h".}
|
||||
|
||||
proc unlink*(loop: PLoop, req: PFS, path: cstring, cb: FsProc): cint{.
|
||||
importc: "uv_fs_unlink", header: "uv.h".}
|
||||
|
||||
proc write*(loop: PLoop, req: PFS, file: TFile, buf: pointer, length: csize, offset: coff, cb: FsProc): cint{.
|
||||
proc write*(loop: PLoop, req: PFS, file: File, buf: pointer, length: csize, offset: coff, cb: FsProc): cint{.
|
||||
importc: "uv_fs_write", header: "uv.h".}
|
||||
|
||||
proc mkdir*(loop: PLoop, req: PFS, path: cstring, mode: cint, cb: FsProc): cint{.
|
||||
@@ -621,22 +621,22 @@ proc readdir*(loop: PLoop, req: PFS, path: cstring, flags: cint, cb: FsProc): ci
|
||||
proc stat*(loop: PLoop, req: PFS, path: cstring, cb: FsProc): cint{.
|
||||
importc: "uv_fs_stat", header: "uv.h".}
|
||||
|
||||
proc fstat*(loop: PLoop, req: PFS, file: TFile, cb: FsProc): cint{.
|
||||
proc fstat*(loop: PLoop, req: PFS, file: File, cb: FsProc): cint{.
|
||||
importc: "uv_fs_fstat", header: "uv.h".}
|
||||
|
||||
proc rename*(loop: PLoop, req: PFS, path: cstring, new_path: cstring, cb: FsProc): cint{.
|
||||
importc: "uv_fs_rename", header: "uv.h".}
|
||||
|
||||
proc fsync*(loop: PLoop, req: PFS, file: TFile, cb: FsProc): cint{.
|
||||
proc fsync*(loop: PLoop, req: PFS, file: File, cb: FsProc): cint{.
|
||||
importc: "uv_fs_fsync", header: "uv.h".}
|
||||
|
||||
proc fdatasync*(loop: PLoop, req: PFS, file: TFile, cb: FsProc): cint{.
|
||||
proc fdatasync*(loop: PLoop, req: PFS, file: File, cb: FsProc): cint{.
|
||||
importc: "uv_fs_fdatasync", header: "uv.h".}
|
||||
|
||||
proc ftruncate*(loop: PLoop, req: PFS, file: TFile, offset: coff, cb: FsProc): cint{.
|
||||
proc ftruncate*(loop: PLoop, req: PFS, file: File, offset: coff, cb: FsProc): cint{.
|
||||
importc: "uv_fs_ftruncate", header: "uv.h".}
|
||||
|
||||
proc sendfile*(loop: PLoop, req: PFS, out_fd: TFile, in_fd: TFile, in_offset: coff, length: csize, cb: FsProc): cint{.
|
||||
proc sendfile*(loop: PLoop, req: PFS, out_fd: File, in_fd: File, in_offset: coff, length: csize, cb: FsProc): cint{.
|
||||
importc: "uv_fs_sendfile", header: "uv.h".}
|
||||
|
||||
proc chmod*(loop: PLoop, req: PFS, path: cstring, mode: cint, cb: FsProc): cint{.
|
||||
@@ -645,7 +645,7 @@ proc chmod*(loop: PLoop, req: PFS, path: cstring, mode: cint, cb: FsProc): cint{
|
||||
proc utime*(loop: PLoop, req: PFS, path: cstring, atime: cdouble, mtime: cdouble, cb: FsProc): cint{.
|
||||
importc: "uv_fs_utime", header: "uv.h".}
|
||||
|
||||
proc futime*(loop: PLoop, req: PFS, file: TFile, atime: cdouble, mtime: cdouble, cb: FsProc): cint{.
|
||||
proc futime*(loop: PLoop, req: PFS, file: File, atime: cdouble, mtime: cdouble, cb: FsProc): cint{.
|
||||
importc: "uv_fs_futime", header: "uv.h".}
|
||||
|
||||
proc lstat*(loop: PLoop, req: PFS, path: cstring, cb: FsProc): cint{.
|
||||
@@ -660,25 +660,25 @@ proc symlink*(loop: PLoop, req: PFS, path: cstring, new_path: cstring, flags: ci
|
||||
proc readlink*(loop: PLoop, req: PFS, path: cstring, cb: FsProc): cint{.
|
||||
importc: "uv_fs_readlink", header: "uv.h".}
|
||||
|
||||
proc fchmod*(loop: PLoop, req: PFS, file: TFile, mode: cint, cb: FsProc): cint{.
|
||||
proc fchmod*(loop: PLoop, req: PFS, file: File, mode: cint, cb: FsProc): cint{.
|
||||
importc: "uv_fs_fchmod", header: "uv.h".}
|
||||
|
||||
proc chown*(loop: PLoop, req: PFS, path: cstring, uid: cint, gid: cint, cb: FsProc): cint{.
|
||||
importc: "uv_fs_chown", header: "uv.h".}
|
||||
|
||||
proc fchown*(loop: PLoop, req: PFS, file: TFile, uid: cint, gid: cint, cb: FsProc): cint{.
|
||||
proc fchown*(loop: PLoop, req: PFS, file: File, uid: cint, gid: cint, cb: FsProc): cint{.
|
||||
importc: "uv_fs_fchown", header: "uv.h".}
|
||||
|
||||
proc event_init*(loop: PLoop, handle: PFSEvent, filename: cstring, cb: FsEventProc): cint{.
|
||||
importc: "uv_fs_event_init", header: "uv.h".}
|
||||
|
||||
proc ip4_addr*(ip: cstring, port: cint): TSockAddrIn{.
|
||||
proc ip4_addr*(ip: cstring, port: cint): SockAddrIn{.
|
||||
importc: "uv_ip4_addr", header: "uv.h".}
|
||||
|
||||
proc ip6_addr*(ip: cstring, port: cint): TSockAddrIn6{.
|
||||
importc: "uv_ip6_addr", header: "uv.h".}
|
||||
|
||||
proc ip4_name*(src: ptr TSockAddrIn, dst: cstring, size: csize): cint{.
|
||||
proc ip4_name*(src: ptr SockAddrIn, dst: cstring, size: csize): cint{.
|
||||
importc: "uv_ip4_name", header: "uv.h".}
|
||||
|
||||
proc ip6_name*(src: ptr TSockAddrIn6, dst: cstring, size: csize): cint{.
|
||||
|
||||
@@ -232,7 +232,7 @@ proc uncompress*(sourceBuf: cstring, sourceLen: int): string =
|
||||
return
|
||||
|
||||
# Make sure memory allocated by inflateInit2() is freed eventually.
|
||||
finally: discard inflateEnd(z)
|
||||
defer: discard inflateEnd(z)
|
||||
|
||||
# Decompress all of self.
|
||||
while true:
|
||||
|
||||
Reference in New Issue
Block a user