diff --git a/utshell-0.5/r_general/src/lib.rs b/utshell-0.5/r_general/src/lib.rs index f2591c8ad12113bab1ae2535c67ca9c6e8f6f1f8..af8336704068c167690a98f7446da374c593862f 100644 --- a/utshell-0.5/r_general/src/lib.rs +++ b/utshell-0.5/r_general/src/lib.rs @@ -1295,4 +1295,31 @@ pub unsafe extern "C" fn file_isdir(mut fn_0: *const libc::c_char) -> libc::c_in }; return (stat(fn_0, &mut sb) == 0 && S_ISDIR!(sb.st_mode)) as libc::c_int; +} + +#[no_mangle] +pub unsafe extern "C" fn file_iswdir(mut fn_0: *const libc::c_char) -> libc::c_int { + return (file_isdir(fn_0) != 0 && sh_eaccess(fn_0, W_OK) == 0 as libc::c_int) as libc::c_int; +} + +/* Return 1 if STRING is "." or "..", optionally followed by a directory +separator */ +#[no_mangle] +pub unsafe extern "C" fn path_dot_or_dotdot(mut string: *const libc::c_char) -> libc::c_int { + if string.is_null() + || *string as libc::c_int == '\0' as i32 + || *string as libc::c_int != '.' as i32 + { + return 0 as libc::c_int; + } + + /* string[0] == '.' */ + if PATHSEP!(*string.offset(1 as isize) as libc::c_int) + || *string.offset(1 as isize) as libc::c_int == '.' as i32 + && PATHSEP!(*string.offset(2 as isize) as libc::c_int) + { + return 1; + } + + return 0; } \ No newline at end of file