on func_posix_shell_exec(cmd)
set result to do shell script cmd
return result
end func_posix_shell_exec
on func_posix_dirname(apath)
set cmd to "dirname" & space & quoted form of apath
return func_posix_shell_exec(cmd)
end func_posix_dirname
on func_posix_basename(apath)
set cmd to "basename" & space & quoted form of apath
return func_posix_shell_exec(cmd)
end func_posix_basename
on func_posix_is_kind_opt(apath, flags)
set cmd to "eval 'if [ " & flags & space & quoted form of apath & " ]; then echo 1; else echo 0; fi' 2>&1"
return func_posix_shell_exec(cmd)
end func_posix_is_file
on func_posix_is_file(apath)
return func_posix_is_kind_opt(apath, "-f")
end func_posix_is_file
on func_posix_is_dir(apath)
return func_posix_is_kind_opt(apath, "-d")
end func_posix_is_dir
on func_posix_create_dir(dirpath)
set cmd to "/bin/mkdir -p " & quoted form of dirpath & " 2>&1"
return func_posix_shell_exec(cmd)
end func_posix_create_dir
on func_posix_create_rmdir_opt(dirpath, flags)
set cmd to "/bin/rmdir" & space & flags & space & quoted form of dirpath & " 2>&1"
return func_posix_shell_exec(cmd)
end func_posix_create_rmdir_opt
on func_posix_create_rmdir(dirpath)
return func_posix_create_rmdir_opt(dirpath, "-f")
end func_posix_create_rmdir
on func_posix_create_rmdir_r(dirpath)
return func_posix_create_rmdir_opt(dirpath, "-Rf")
end func_posix_create_rmdir_r
on func_posix_create_rmfile_opt(filepath, flags)
set cmd to "/bin/rm" & space & flags & space & quoted form of filepath & " 2>&1"
return func_posix_shell_exec(cmd)
end func_posix_create_rmfile_opt
on func_posix_create_rmfile(filepath)
return func_posix_create_rmdir_opt(filepath, "-f")
end func_posix_create_rmfile
on func_posix_copy_dir_opt(src_dirpath, dest_dirpath, flags)
set cmd to "/usr/bin/ditto" & space & flags & space & quoted form of src_dirpath & space & quoted form of dest_dirpath
return func_posix_shell_exec(cmd)
end func_posix_copy_dir_opt
on func_posix_copy_file_opt(src_filepath, dest_filepath, flags)
set cmd to "/bin/cp" & space & flags & space & quoted form of src_filepath & space & quoted form of dest_filepath
return func_posix_shell_exec(cmd)
end func_posix_copy_file_opt
on func_posix_copy_dir(src_dirpath, dest_dirpath, flags)
return func_posix_copy_dir_opt(src_dirpath, dest_dirpath, "-rsrc")
end func_posix_copy_dir
on func_posix_copy_file(src_filepath, dest_dirpath)
set bname to func_posix_basename(src_filepath)
set dest to dest_dirpath & "/" & bname
return func_posix_copy_file_opt(src_filepath, dest, "-f")
end func_posix_copy_file
--
set p to POSIX path of (path to application "Finder")
set posix_dirname to func_posix_dirname(p)
set posix_basename to func_posix_basename(p)
-- EOF