From 328e9f6d64ab545821527d29d323d7071204a91b Mon Sep 17 00:00:00 2001 From: Wesley Kerfoot Date: Sat, 30 Nov 2019 21:06:19 -0500 Subject: [PATCH] Allow passing permission into SEND as string of octal --- adb.nim | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/adb.nim b/adb.nim index aa8407b..15d6fc3 100644 --- a/adb.nim +++ b/adb.nim @@ -177,7 +177,7 @@ proc statFile(filename : string) : Option[FileStat] = else: none(FileStat) -proc adbSend(buf : string, filename : string) : bool = +proc adbSend(buf : string, filename : string, permissions : string) : bool = let stat = filename.statFile if stat.isSome: @@ -187,7 +187,7 @@ proc adbSend(buf : string, filename : string) : bool = # Enter sync mode let socket : Socket = syncMode() - let fileMode = fromOct[int]("0771") + let fileMode = fromOct[int](fmt"0{permissions}") let lmtime = getTime().toUnix.uint32.unrollBytes let remoteFileName = fmt"{filename},{fileMode:04o}" let chunks = buf.chunkString @@ -256,3 +256,6 @@ proc devices() : Option[string] = makeMsg("host:version").runCommand.parseAdb discard execCmd("adb start-server") + +echo adbSend("This\nIs\nA\nTest\n", "/storage/7AFD-17E3/testmyshit", "777") +echo adbPull("/storage/7AFD-17E3/testmyshit").get.androidFile