@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; } }
/** * 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; }