mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
string: make substr() copy the data, like in Java and C#; remove .cstr()
this makes managing memory used by strings much easier V strings are now fully compatible with C strings
This commit is contained in:
@ -53,8 +53,8 @@ pub fn open(name string, level int, mode string) ?zip_ptr {
|
||||
if mode != M_WRITE && mode != M_RONLY && mode != M_APPEND {
|
||||
return error('szip: invalid provided open mode')
|
||||
}
|
||||
/* struct zip_t* */_p_zip := zip_ptr(C.zip_open(name.cstr(),
|
||||
_nlevel, mode.cstr()))
|
||||
/* struct zip_t* */_p_zip := zip_ptr(C.zip_open(name.str,
|
||||
_nlevel, mode.str))
|
||||
if _p_zip == zip_ptr(0) {
|
||||
return error('szip: cannot open/create/append new zip archive.')
|
||||
}
|
||||
@ -83,7 +83,7 @@ pub fn (z mut zip_ptr) close() {
|
||||
* @return the return code - 0 on success, negative number (< 0) on error.
|
||||
*/
|
||||
pub fn (zentry mut zip_ptr) open_entry(name string) /*?*/bool {
|
||||
res := C.zip_entry_open(zentry, name.cstr())
|
||||
res := C.zip_entry_open(zentry, name.str)
|
||||
return res != -1
|
||||
}
|
||||
|
||||
@ -203,7 +203,7 @@ pub fn (zentry mut zip_ptr) write_entry(data []byte) bool {
|
||||
* @return the return code - 0 on success, negative number (< 0) on error.
|
||||
*/
|
||||
pub fn (zentry mut zip_ptr) create_entry(name string) bool {
|
||||
res := C.zip_entry_fwrite(zentry, name.cstr())
|
||||
res := C.zip_entry_fwrite(zentry, name.str)
|
||||
return res == 0
|
||||
}
|
||||
|
||||
@ -241,11 +241,11 @@ pub fn (zentry mut zip_ptr) read_entry() ?voidptr {
|
||||
* @return the return code - 0 on success, negative number (< 0) on error.
|
||||
*/
|
||||
pub fn (zentry mut zip_ptr) extract_entry(path string) /*?*/bool {
|
||||
if C.access(path.cstr(), 0) == -1 {
|
||||
if C.access(path.str, 0) == -1 {
|
||||
return false
|
||||
//return error('Cannot open file for extracting, file not exists')
|
||||
}
|
||||
res := C.zip_entry_fread(zentry, path.cstr())
|
||||
res := C.zip_entry_fread(zentry, path.str)
|
||||
return res == 0
|
||||
}
|
||||
|
||||
@ -260,11 +260,11 @@ pub fn (zentry mut zip_ptr) extract_entry(path string) /*?*/bool {
|
||||
* @return the return code - 0 on success, negative number (< 0) on error.
|
||||
*/
|
||||
/*fn (zentry mut zip_ptr) extract(path string) bool {
|
||||
if C.access(path.cstr(), 0) == -1 {
|
||||
if C.access(path.str, 0) == -1 {
|
||||
return false
|
||||
//return error('Cannot open directory for extracting, directory not exists')
|
||||
}
|
||||
res := C.zip_extract(zentry, path.cstr(), 0, 0)
|
||||
res := C.zip_extract(zentry, path.str, 0, 0)
|
||||
return res == 0
|
||||
}*/
|
||||
|
||||
|
Reference in New Issue
Block a user