This repository was archived by the owner on Jul 24, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +43
-10
lines changed
Expand file tree Collapse file tree 3 files changed +43
-10
lines changed Original file line number Diff line number Diff line change @@ -91,16 +91,6 @@ func int2err(i C.int) error {
9191 return & gopy_err {fmt .Sprintf ("error in C-Python (rc=%i)" , int (i ))}
9292}
9393
94- // file2py opens a stdC file from a Go os.File. Note the returned file has
95- // been newly opened: the caller must close it with C.fclose(retval).
96- func file2py (f * os.File , mode string ) * C.FILE {
97- cmode := C .CString (mode )
98- defer C .free (unsafe .Pointer (cmode ))
99- fd := f .Fd ()
100- file := C .fdopen (C .int (fd ), cmode )
101- return file
102- }
103-
10494func file2go (f * C.FILE ) * os.File {
10595 return nil
10696}
Original file line number Diff line number Diff line change 1+ package python
2+
3+ //#include <stdlib.h>
4+ //#include <string.h>
5+ //#include <stdio.h>
6+ import "C"
7+
8+ import (
9+ "os"
10+ "unsafe"
11+ )
12+
13+ // file2py opens a stdC file from a Go os.File. Note the returned file has
14+ // been newly opened: the caller must close it with C.fclose(retval).
15+ func file2py (f * os.File , mode string ) * C.FILE {
16+ cmode := C .CString (mode )
17+ defer C .free (unsafe .Pointer (cmode ))
18+ fd := f .Fd ()
19+ file := C .fdopen (C .int (fd ), cmode )
20+ return file
21+ }
Original file line number Diff line number Diff line change 1+ package python
2+
3+ //#include <stdlib.h>
4+ //#include <string.h>
5+ //#include <stdio.h>
6+ import "C"
7+
8+ import (
9+ "os"
10+ "unsafe"
11+ )
12+
13+ // file2py opens a stdC file from a Go os.File. Note the returned file has
14+ // been newly opened: the caller must close it with C.fclose(retval).
15+ func file2py (f * os.File , mode string ) * C.FILE {
16+ cmode := C .CString (mode )
17+ defer C .free (unsafe .Pointer (cmode ))
18+ name := C .CString (file .Name ())
19+ defer C .free (unsafe .Pointer (name ))
20+ file := C .fopen (name , cmode )
21+ return file
22+ }
You can’t perform that action at this time.
0 commit comments