public FileStat fstat(int fd) { WindowsFileStat stat = new WindowsFileStat(this); if (fstat(fd, stat) < 0) handler.error(Errno.valueOf(errno()), "fstat", "" + fd); return stat; }
public FileStat fstat(int fd) { WindowsFileStat stat = new WindowsFileStat(this); if (fstat(fd, stat) < 0) handler.error(Errno.valueOf(errno()), "fstat", "" + fd); return stat; }
public FileStat fstat(int fd) { WindowsFileStat stat = new WindowsFileStat(this); if (fstat(fd, stat) < 0) handler.error(Errno.valueOf(errno()), "fstat", "" + fd); return stat; }
@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 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 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 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 mkdir(String path, int mode) { WString widePath = WString.path(path); int res = -1; if (wlibc()._wmkdir(widePath) == 0) { res = wlibc()._wchmod(widePath, mode); } if (res < 0) { int errno = errno(); handler.error(Errno.valueOf(errno), "mkdir", path); } return res; }
@Override public int mkdir(String path, int mode) { WString widePath = WString.path(path); int res = -1; if (wlibc()._wmkdir(widePath) == 0) { res = wlibc()._wchmod(widePath, mode); } if (res < 0) { int errno = errno(); handler.error(Errno.valueOf(errno), "mkdir", path); } return res; }
@Override public int mkdir(String path, int mode) { WString widePath = WString.path(path); int res = -1; if (wlibc()._wmkdir(widePath) == 0) { res = wlibc()._wchmod(widePath, mode); } if (res < 0) { int errno = errno(); handler.error(Errno.valueOf(errno), "mkdir", path); } return res; }
@Override public int mkdir(String path, int mode) { WString widePath = WString.path(path); int res = -1; if (wlibc()._wmkdir(widePath) == 0) { res = wlibc()._wchmod(widePath, mode); } if (res < 0) { int errno = errno(); handler.error(Errno.valueOf(errno), "mkdir", path); } return res; }
@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; }
@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; }
@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; }
/** * The logic here is a bit strange and this copies MRI (Ruby) which may not be language * agnostic, but windows (win7 and others) automatically mark folders as read-only when * it contains other files and folders within it. This document explains more: * http://support.microsoft.com/kb/326549 * I think the logic is based around idea that if you removed all other files it would * be empty but will stay marked as read-only. */ @Override public int rmdir(String path) { WString pathW = WString.path(path); int attr = wlibc().GetFileAttributesW(pathW); boolean isReadOnly = attr != INVALID_FILE_ATTRIBUTES && (attr & FILE_ATTRIBUTE_READONLY) != 0; if (isReadOnly) wlibc().SetFileAttributesW(pathW, attr & ~FILE_ATTRIBUTE_READONLY); if (!wlibc().RemoveDirectoryW(pathW)) { int errno = errno(); if (isReadOnly) wlibc().SetFileAttributesW(pathW, attr & FILE_ATTRIBUTE_READONLY); handler.error(mapErrorToErrno(errno), "rmdir", path); return -1; } return 0; }
/** * The logic here is a bit strange and this copies MRI (Ruby) which may not be language * agnostic, but windows (win7 and others) automatically mark folders as read-only when * it contains other files and folders within it. This document explains more: * http://support.microsoft.com/kb/326549 * I think the logic is based around idea that if you removed all other files it would * be empty but will stay marked as read-only. */ @Override public int rmdir(String path) { WString pathW = WString.path(path); int attr = wlibc().GetFileAttributesW(pathW); boolean isReadOnly = attr != INVALID_FILE_ATTRIBUTES && (attr & FILE_ATTRIBUTE_READONLY) != 0; if (isReadOnly) wlibc().SetFileAttributesW(pathW, attr & ~FILE_ATTRIBUTE_READONLY); if (!wlibc().RemoveDirectoryW(pathW)) { int errno = errno(); if (isReadOnly) wlibc().SetFileAttributesW(pathW, attr & FILE_ATTRIBUTE_READONLY); handler.error(mapErrorToErrno(errno), "rmdir", path); return -1; } return 0; }
/** * The logic here is a bit strange and this copies MRI (Ruby) which may not be language * agnostic, but windows (win7 and others) automatically mark folders as read-only when * it contains other files and folders within it. This document explains more: * http://support.microsoft.com/kb/326549 * I think the logic is based around idea that if you removed all other files it would * be empty but will stay marked as read-only. */ @Override public int rmdir(String path) { WString pathW = WString.path(path); int attr = wlibc().GetFileAttributesW(pathW); boolean isReadOnly = attr != INVALID_FILE_ATTRIBUTES && (attr & FILE_ATTRIBUTE_READONLY) != 0; if (isReadOnly) wlibc().SetFileAttributesW(pathW, attr & ~FILE_ATTRIBUTE_READONLY); if (!wlibc().RemoveDirectoryW(pathW)) { int errno = errno(); if (isReadOnly) wlibc().SetFileAttributesW(pathW, attr & FILE_ATTRIBUTE_READONLY); handler.error(mapErrorToErrno(errno), "rmdir", path); return -1; } return 0; }
/** * The logic here is a bit strange and this copies MRI (Ruby) which may not be language * agnostic, but windows (win7 and others) automatically mark folders as read-only when * it contains other files and folders within it. This document explains more: * http://support.microsoft.com/kb/326549 * I think the logic is based around idea that if you removed all other files it would * be empty but will stay marked as read-only. * * @param path the path to remove * @return 0 if successful, -1 if failed */ @Override public int rmdir(String path) { WString pathW = WString.path(path); int attr = wlibc().GetFileAttributesW(pathW); boolean isReadOnly = attr != INVALID_FILE_ATTRIBUTES && (attr & FILE_ATTRIBUTE_READONLY) != 0; if (isReadOnly) wlibc().SetFileAttributesW(pathW, attr & ~FILE_ATTRIBUTE_READONLY); if (!wlibc().RemoveDirectoryW(pathW)) { int errno = errno(); if (isReadOnly) wlibc().SetFileAttributesW(pathW, attr & FILE_ATTRIBUTE_READONLY); handler.error(mapErrorToErrno(errno), "rmdir", path); return -1; } return 0; }