1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

all: switch to the new fn arg syntax everywhere; add lots of vfmt -verify tests

This commit is contained in:
Alexander Medvednikov
2020-10-15 12:32:28 +02:00
parent 982056894e
commit 7da1afa140
37 changed files with 382 additions and 404 deletions

View File

@ -70,7 +70,7 @@ pub fn (mut f File) write_bytes(data voidptr, size int) int {
return C.fwrite(data, 1, size, f.cfile)
}
pub fn (mut f File) write_bytes_at(data voidptr, size, pos int) int {
pub fn (mut f File) write_bytes_at(data voidptr, size int, pos int) int {
C.fseek(f.cfile, pos, C.SEEK_SET)
res := C.fwrite(data, 1, size, f.cfile)
C.fseek(f.cfile, 0, C.SEEK_END)
@ -84,7 +84,7 @@ pub fn (f &File) read_bytes(size int) []byte {
}
// read_bytes_at reads bytes at the given position in the file
pub fn (f &File) read_bytes_at(size, pos int) []byte {
pub fn (f &File) read_bytes_at(size int, pos int) []byte {
mut arr := []byte{len: size}
nreadbytes := f.read_bytes_into(pos, mut arr) or {
// return err

View File

@ -57,7 +57,7 @@ pub fn read_file(path string) ?string {
}
}
/***************************** OS ops ************************/
//***************************** OS ops ************************
// file_size returns the size of the file located in `path`.
pub fn file_size(path string) int {
mut s := C.stat{}
@ -76,7 +76,7 @@ pub fn file_size(path string) int {
}
// mv moves files or folders from `src` to `dst`.
pub fn mv(src, dst string) {
pub fn mv(src string, dst string) {
mut rdst := dst
if is_dir(rdst) {
rdst = join_path(rdst.trim_right(path_separator),file_name(src.trim_right(path_separator)))
@ -91,7 +91,7 @@ pub fn mv(src, dst string) {
}
// cp copies files or folders from `src` to `dst`.
pub fn cp(src, dst string) ? {
pub fn cp(src string, dst string) ? {
$if windows {
w_src := src.replace('/', '\\')
w_dst := dst.replace('/', '\\')
@ -135,14 +135,14 @@ pub fn cp(src, dst string) ? {
}
[deprecated]
pub fn cp_r(osource_path, odest_path string, overwrite bool) ? {
pub fn cp_r(osource_path string, odest_path string, overwrite bool) ? {
eprintln('warning: `os.cp_r` has been deprecated, use `os.cp_all` instead')
return cp_all(osource_path, odest_path, overwrite)
}
// cp_all will recursively copy `src` to `dst`,
// optionally overwriting files or dirs in `dst`.
pub fn cp_all(src, dst string, overwrite bool) ? {
pub fn cp_all(src string, dst string, overwrite bool) ? {
source_path := os.real_path(src)
dest_path := os.real_path(dst)
if !os.exists(source_path) {
@ -190,7 +190,7 @@ pub fn mv_by_cp(source string, target string) ? {
// vfopen returns an opened C file, given its path and open mode.
// NB: os.vfopen is useful for compatibility with C libraries, that expect `FILE *`.
// If you write pure V code, os.create or os.open are more convenient.
pub fn vfopen(path, mode string) ?&C.FILE {
pub fn vfopen(path string, mode string) ?&C.FILE {
if path.len == 0 {
return error('vfopen called with ""')
}
@ -858,7 +858,7 @@ pub fn home_dir() string {
}
// write_file writes `text` data to a file in `path`.
pub fn write_file(path, text string) ? {
pub fn write_file(path string, text string) ? {
mut f := os.create(path)?
f.write(text)
f.close()
@ -1164,7 +1164,7 @@ pub fn join_path(base string, dirs ...string) string {
}
// walk_ext returns a recursive list of all files in `path` ending with `ext`.
pub fn walk_ext(path, ext string) []string {
pub fn walk_ext(path string, ext string) []string {
if !os.is_dir(path) {
return []
}

View File

@ -159,7 +159,7 @@ pub fn exec(cmd string) ?Result {
}
}
pub fn symlink(origin, target string) ?bool {
pub fn symlink(origin string, target string) ?bool {
res := C.symlink(charptr(origin.str), charptr(target.str))
if res == 0 {
return true