Open SuperSamus opened 9 months ago
../go/pkg/mod/github.com/itchio/dmcunrar-go@v0.0.0-20200303200038-d0b2e3ba28f6/dmcunrar/glue.go:179:11: cannot define new methods on non-local type *C.dmc_unrar_file
As a workaround, editing glue.go
and adding a typedef while changing the function type seems to work:
+type dmcUnrarFile C.dmc_unrar_file
-func (fs *C.dmc_unrar_file) GetUncompressedSize() int64 {
+func (fs *dmcUnrarFile) GetUncompressedSize() int64 {
return int64(fs.uncompressed_size)
}
https://github.com/itchio/dmcunrar-go/blob/master/dmcunrar/glue.go#L179-L181
diff --git a/dmcunrar/glue.go b/dmcunrar/glue.go
index 3c2fe63..51d7b79 100644
--- a/dmcunrar/glue.go
+++ b/dmcunrar/glue.go
@@ -165,8 +165,9 @@ func (a *Archive) GetFilename(i int64) (string, error) {
return C.GoString(filename), nil
}
-func (a *Archive) GetFileStat(i int64) *C.dmc_unrar_file {
- return C.dmc_unrar_get_file_stat(a.archive, C.dmc_unrar_size_t(i))
+func (a *Archive) GetFileStat(i int64) *dmcUnrarFile {
+ var f *C.dmc_unrar_file = C.dmc_unrar_get_file_stat(a.archive, C.dmc_unrar_size_t(i))
+ return (*dmcUnrarFile)(unsafe.Pointer(f))
}
func (a *Archive) FileIsDirectory(i int64) bool {
Both on release v15.21.0 and on the current latest commit 50d55e90a90f4d03b5cfc7d35d135b30584c91a7, when building with Go 1.21:
(The weird path names are because I'm compiling on NixOS)
Compiles fine with Go 1.20.