|
From: Panayotis K. <pan...@pa...> - 2011-05-04 17:38:00
|
On May 4, 2011, at 7:06 PM, Domenico De Fano wrote:
> Hi all,
>
> I'm encountering a problem while reading files from my java2objc application. I have a number of files stored in a res
> folder of my project which I set in the configuration file as to be the resources folder.
> When I try to load icons I use in the application, using the UIImage class, everything works fine.
> If I try to read files using the FileInputStream class, I need to specify the absolute file path, or there is no way the files can be found.
> I couldn't understand why this happens, thus, I looked into the Objective-C compatibility libraries for the implementation of the classes. Following the FileInputStream implementation,
> I ended up in the java_io_File.m class, and the following method:
>
> - (void) __init_java_io_File___java_lang_String: (java_lang_String*) pathname
> {
> if (pathname==JAVA_NULL || [pathname length] == 0 || [pathname characterAtIndex:0] != '/') {
> // For relative paths, prepend the base directory of <App>/Documents/
> // http://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/FilesandNetworking/FilesandNetworking.html
> NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
> path = [[NSMutableString alloc] init];
> [path setString:[paths objectAtIndex:0]];
> [path appendFormat:@"/%@", pathname];
> } else {
> path = [[pathname copyWithZone: NULL] retain];
> }
> }
>
> Which appends my file path to the Documents base directory of the app. How should I set the relative path for files located
> in a resources subfolder?
>
> Thanks
Probably I didn't understand the question, byt why not prepend the "res/" part before the filename? |