19 messages in net.java.dev.jna.usersRe: Identifying symbolic links on Mac...
FromSent OnAttachments
Timothy WallDec 11, 2007 5:34 am 
Normen MüllerDec 11, 2007 6:35 am 
Normen MüllerDec 11, 2007 6:52 am 
Timothy WallDec 11, 2007 7:20 am 
Timothy WallDec 11, 2007 7:53 am 
Timothy WallDec 11, 2007 7:55 am 
Nikolas LotzDec 11, 2007 8:05 am 
Normen MüllerDec 11, 2007 8:27 am 
Normen MüllerDec 11, 2007 8:37 am 
Timothy WallDec 11, 2007 10:25 am 
Duncan McGregorDec 11, 2007 3:05 pm 
Normen MüllerDec 12, 2007 12:04 am 
Peter ReillyDec 12, 2007 1:34 am 
Normen MüllerDec 12, 2007 1:39 am 
Timothy WallDec 12, 2007 4:34 am 
Timothy WallDec 12, 2007 4:38 am 
Normen MüllerDec 12, 2007 4:57 am 
Normen MüllerDec 12, 2007 5:04 am 
Timothy WallDec 12, 2007 5:36 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: Identifying symbolic links on Mac OSX 10.5.1Actions...
From:Normen Müller (n.mu@jacobs-university.de)
Date:Dec 11, 2007 6:35:18 am
List:net.java.dev.jna.users

Timothy Wall <twalljava@...> writes:

Several things to look at: 1) how is the C library loaded? is it loaded properly on OSX (i.e. do you get an instance of ISVNCLibrary)?

Yes, I think so. In debug mode the debugger outputs

Proxy interface to Native Library </usr/lib/libc.dylib@2414037576>

when I click on cLibrary in the line

ISVNCLibrary cLibrary = JNALibraryLoader.getCLibrary();

2) how is lstat defined on OSX 10.5.1? in glibc, it is a macro that points to _xstat

I have no clue about the definition of lstat on OSX 10.5.1, guess that's the real problem. I was hoping the SVNKit guys already did it right ;-)

I would recommend writing a small unit test program that reproduces the SVNKit code, then you can instrument it as needed to figure out where it is failing.

That's, what I am doing. Currently I am not using the whole SVNKit library but just testing this SVNLinuxUtil class:

class SVNLinuxUtil { private static Memory ourSharedMemory; static { try { ourSharedMemory = new Memory(1024); } catch (Throwable th) { ourSharedMemory = null; } }

public static SVNFileType getFileType(File file) { if (file == null || ourSharedMemory == null) { return null; } String path = file.getAbsolutePath(); if (path.endsWith("/") && path.length() > 1) { path = path.substring(0, path.length() - 1); } try { ISVNCLibrary cLibrary = JNALibraryLoader.getCLibrary(); if (cLibrary == null) { return null; } synchronized (ourSharedMemory) { ourSharedMemory.clear(); int rc; synchronized (cLibrary) { rc = SVNFileUtil.isOSX || SVNFileUtil.isBSD ? cLibrary.lstat(path, ourSharedMemory) : cLibrary.__lxstat64(0, path, ourSharedMemory); } if (rc < 0) { if (file.exists() || file.isDirectory() || file.isFile()) { return null; } return SVNFileType.NONE; } int mode = SVNFileUtil.isOSX || SVNFileUtil.isBSD ? ourSharedMemory.getInt(8) : ourSharedMemory.getInt(16); int type = mode & 0170000; if (type == 0120000) { return SVNFileType.SYMLINK; } else if (type == 0040000) { return SVNFileType.DIRECTORY; } else if (type == 0100000) { return SVNFileType.FILE; } else { if (file.exists() || file.isDirectory() || file.isFile()) { return null; } return SVNFileType.NONE; } } } catch (Throwable th) { // } return null; } }

On Dec 11, 2007, at 7:12 AM, Normen Müller wrote:

Dear JNA developers,

could you point me to an example on how to identifying symbolic links on Mac OS 10.5.1?

Currently I am using SVNKit <at> HEAD which pointed my to your library. In SVNKit there is a function for identifying file types, but on my Mac OS X 10.5.1 it always returns null, no matter if I commit a symbolic link to a directory or to a file.

Do you have any ideas how to fix this?

In the following is a copy of getFileType function out of the SVNKit library:

public static SVNFileType getFileType(File file) { if (file == null || ourSharedMemory == null) { return null; } String path = file.getAbsolutePath(); if (path.endsWith("/") && path.length() > 1) { path = path.substring(0, path.length() - 1); } try { ISVNCLibrary cLibrary = JNALibraryLoader.getCLibrary(); if (cLibrary == null) { return null; } synchronized (ourSharedMemory) { ourSharedMemory.clear(); int rc; synchronized (cLibrary) { rc = SVNFileUtil.isOSX || SVNFileUtil.isBSD ? cLibrary.lstat(path, ourSharedMemory) : cLibrary.__lxstat64(0, path, ourSharedMemory); } if (rc < 0) { if (file.exists() || file.isDirectory() || file.isFile()) { return null; } return SVNFileType.NONE; } int mode = SVNFileUtil.isOSX || SVNFileUtil.isBSD ? ourSharedMemory.getInt(8) : ourSharedMemory.getInt(16); int type = mode & 0170000; if (type == 0120000) { return SVNFileType.SYMLINK; } else if (type == 0040000) { return SVNFileType.DIRECTORY; } else if (type == 0100000) { return SVNFileType.FILE; } else { if (file.exists() || file.isDirectory() || file.isFile()) { return null; } return SVNFileType.NONE; } } } catch (Throwable th) { // } return null; }

I would appreciate your help, /nm