Skip to content

Commit e92b185

Browse files
committed
o Java 7 file attributes now work on Windows ( TM )
1 parent 05b1968 commit e92b185

File tree

4 files changed

+13
-19
lines changed

4 files changed

+13
-19
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,7 @@ target/
33
.classpath
44
.settings/
55
bin
6+
*.ipr
7+
*.iml
8+
*.iws
9+

src/main/java/org/codehaus/plexus/components/io/attributes/Java7Reflector.java

-15
Original file line numberDiff line numberDiff line change
@@ -110,26 +110,11 @@ public class Java7Reflector
110110
public static Object getPosixFileAttributes( File file )
111111
throws IOException
112112
{
113-
/* final Path path = file.toPath();
114-
115-
final PosixFileAttributes posixFileAttributes =
116-
Files.readAttributes( path, PosixFileAttributes.class, LinkOption.NOFOLLOW_LINKS );
117-
*/
118113
final Object path = invoke( pathMethod, file );
119114

120115
return invoke( readAttributes, null, path, posixFileAttributes, arr );
121116
}
122117

123-
/*
124-
final UserPrincipal ownerUserPrincipal = posixFileAttributes.owner();
125-
this.userName = ownerUserPrincipal.getName();
126-
this.groupName = posixFileAttributes.group().getName();
127-
128-
final Set<PosixFilePermission> permissions = posixFileAttributes.permissions();
129-
mode = PosixFilePermissions.toString( permissions ).toCharArray();
130-
131-
132-
*/
133118
public static String getOwnerUserName( Object posixFileAttributes )
134119
{
135120
/*

src/main/java/org/codehaus/plexus/components/io/attributes/PlexusIoResourceAttributeUtils.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -213,16 +213,17 @@ public static Map<String, PlexusIoResourceAttributes> getFileAttributesByPath( F
213213
boolean includeNumericUserId )
214214
throws IOException
215215
{
216-
if ( Java7Reflector.isJava7() )
217-
{
218-
return getFileAttributesByPathJava7( dir, recursive );
219-
}
220216
if ( !enabledOnCurrentOperatingSystem() )
221217
{
222218
//noinspection unchecked
223219
return Collections.EMPTY_MAP;
224220
}
225221

222+
if ( Java7Reflector.isJava7() )
223+
{
224+
return getFileAttributesByPathJava7( dir, recursive );
225+
}
226+
226227
if ( logger == null )
227228
{
228229
logger = new ConsoleLogger( Logger.LEVEL_INFO, "Internal" );

src/test/java/org/codehaus/plexus/components/io/attributes/PlexusIoResourceAttributeUtilsTest.java

+4
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ public void testFolderJava7()
7575
throws IOException
7676
{
7777

78+
if (Os.isFamily( Os.FAMILY_WINDOWS ) || Os.isFamily( Os.FAMILY_WIN9X )){
79+
return; // Nothing to do here.
80+
}
81+
7882
URL resource = Thread.currentThread().getContextClassLoader().getResource(
7983
getClass().getName().replace( '.', '/' ) + ".class" );
8084

0 commit comments

Comments
 (0)