Last active
July 8, 2020 20:04
-
-
Save SilentGopherLnx/02f95486fe474a8337f474cdbac25eac to your computer and use it in GitHub Desktop.
go unrar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
. "github.com/SilentGopherLnx/easygolang" | |
unrar "github.com/gen2brain/go-unarr" | |
) | |
//https://github.com/gen2brain/go-unarr | |
func main() { | |
args := AppRunArgs() | |
if len(args) < 2 { | |
Prln("no enough args") | |
AppExit(1) | |
} | |
arg1 := ArgBugFix(args[1]) | |
go func() { | |
SleepMS(1000 * 5) | |
WriteErr("timeout!") | |
AppExit(7) | |
}() | |
a, err1 := unrar.NewArchive(arg1) | |
if err1 != nil { | |
WriteErr("wrong file: " + err1.Error() + "||" + arg1) | |
AppExit(2) | |
} | |
defer a.Close() | |
if len(args) > 2 { | |
arg2 := ArgBugFix(args[2]) | |
err2 := a.Extract(arg2) | |
if err2 != nil { | |
WriteErr("extaction err[" + arg1 + "||" + arg2 + "]: " + err2.Error()) | |
AppExit(3) | |
} | |
} else { | |
list0, err3 := a.List() | |
if err3 != nil { | |
WriteErr("list err: " + err3.Error()) | |
AppExit(4) | |
} | |
list_txt := StringJoin(list0, "\n") | |
FileTextWrite(FolderLocation_App()+"unrar_list.txt", list_txt) | |
} | |
Prln("done") | |
} | |
func WriteErr(err string) { | |
Prln(err) | |
FileTextWrite(FolderLocation_App()+"unrar_err.txt", AppRunArgs()[1]+"\n"+err) | |
} | |
func ArgBugFix(arg string) string { | |
comma := "\"" | |
a := arg | |
if StringPart(a, 1, 1) == comma { | |
a = StringPart(a, 2, 0) | |
} | |
if StringEnd(a, 1) == comma { | |
a = StringPart(a, 1, StringLength(a)-1) | |
} | |
return a | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#sudo apt-get install gcc-mingw-w64-x86-64 - install for compile to win64 | |
./rsrc -arch="amd64" -ico="icon.ico" -manifest="win_manifest.txt" -o="rsrc.syso" | |
export GOPATH=$HOME/go:/usr/local/go:/mnt/dm-1/golang/my_code/MY_LIB/ | |
export GOOS=windows | |
export GOARCH=amd64 | |
export CGO_ENABLED=1 | |
export CC=x86_64-w64-mingw32-gcc | |
go build -o unrar_win64.exe | |
#-ldflags -H=windowsgui | |
rm rsrc.syso | |
echo "finished: windows64" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | |
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> | |
<assemblyIdentity | |
version="1.0.0.0" | |
processorArchitecture="amd64" | |
name="unrar_win64.exe" | |
type="win32" | |
/> | |
<description>SQL 1C App</description> | |
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"> | |
<security> | |
<requestedPrivileges> | |
<requestedExecutionLevel level="asInvoker"/> | |
</requestedPrivileges> | |
</security> | |
</trustInfo> | |
</assembly> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment