public static POSIX loadWindowsPOSIX(POSIXHandler handler) { return new WindowsPOSIX(DefaultLibCProvider.INSTANCE, handler); }
/** * @param overlay is P_OVERLAY if true and P_NOWAIT if false * @param command full command string * @param program program to be invoked * @param path is path to be searched when needed (delimited by ; on windows) * * @return the pid */ public int spawn(boolean overlay, String command, String program, String path, String[] envp) { if (command == null) return -1; String[] cmds = WindowsHelpers.processCommandLine(this, command, program, path); return childResult(createProcess("spawn", cmds[0], cmds[1], null, null, null, null, envp), overlay); }
@Override public int link(String oldpath, String newpath) { boolean linkCreated = wlibc().CreateHardLinkW(WString.path(newpath), WString.path(oldpath), null); if (!linkCreated) { int error = errno(); handler.error(mapErrorToErrno(error), "link", oldpath + " or " + newpath); return error; } else { return 0; } }
public int findFirstFile(String path, FileStat stat) { byte[] wpath = WString.path(path, true); WindowsFindData findData = new WindowsFindData(getRuntime()); HANDLE handle = wlibc().FindFirstFileW(wpath, findData); if (!handle.isValid()) return -1; wlibc().FindClose(handle); ((WindowsRawFileStat) stat).setup(path, findData); return 0; }
@Override public int stat(String path, FileStat stat) { WindowsFileInformation info = new WindowsFileInformation(getRuntime()); byte[] wpath = WString.path(path, true); if (wlibc().GetFileAttributesExW(wpath, 0, info) != 0) { ((WindowsRawFileStat) stat).setup(path, info); } else { int e = errno(); if (e == ERROR_FILE_NOT_FOUND.intValue() || e == ERROR_PATH_NOT_FOUND.intValue() || e == ERROR_BAD_NETPATH.intValue()) { return -1; } return findFirstFile(path, stat); } return 0; }
private WindowsLibC wlibc() { return (WindowsLibC) libc(); }
@Override public FileStat lstat(String path) { return stat(path); }
public Timeval allocateTimeval() { return new DefaultNativeTimeval(getRuntime()); }
@Override public int link(String oldpath, String newpath) { boolean linkCreated = wlibc().CreateHardLinkW(WString.path(newpath), WString.path(oldpath), null); if (!linkCreated) { int error = errno(); handler.error(mapErrorToErrno(error), "link", oldpath + " or " + newpath); return error; } else { return 0; } }
@Override public int fstat(FileDescriptor fileDescriptor, FileStat stat) { WindowsByHandleFileInformation info = new WindowsByHandleFileInformation(getRuntime()); if (wlibc().GetFileInformationByHandle(JavaLibCHelper.gethandle(fileDescriptor), info) == 0) return -1; ((WindowsRawFileStat) stat).setup(info); return 0; }
@Override public int stat(String path, FileStat stat) { WindowsFileInformation info = new WindowsFileInformation(getRuntime()); byte[] wpath = WString.path(path, true); if (wlibc().GetFileAttributesExW(wpath, 0, info) != 0) { ((WindowsRawFileStat) stat).setup(path, info); } else { int e = errno(); if (e == ERROR_FILE_NOT_FOUND.intValue() || e == ERROR_PATH_NOT_FOUND.intValue() || e == ERROR_BAD_NETPATH.intValue()) { return -1; } return findFirstFile(path, stat); } return 0; }
private WindowsLibC wlibc() { return (WindowsLibC) libc(); }
@Override public FileStat lstat(String path) { return stat(path); }
private FileTime nullFileTime() { FileTime fileTime = new FileTime(getRuntime()); fileTime.dwLowDateTime.set(0); fileTime.dwHighDateTime.set(0); return fileTime; }
@Override public int link(String oldpath, String newpath) { boolean linkCreated = wlibc().CreateHardLinkW(WString.path(newpath), WString.path(oldpath), null); if (!linkCreated) { int error = errno(); handler.error(mapErrorToErrno(error), "link", oldpath + " or " + newpath); return error; } else { return 0; } }