~ubuntu-branches/ubuntu/vivid/emscripten/vivid

« back to all changes in this revision

Viewing changes to tests/nbody-java/native_org_xmlvm_runtime_XMLVMUtil.c

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2013-06-11 15:45:24 UTC
  • mfrom: (1.2.1) (2.1.1 experimental)
  • Revision ID: package-import@ubuntu.com-20130611154524-rppb3w6tixlegv4n
Tags: 1.4.7~20130611~a1eb425-1
* New snapshot release
* Upload to unstable

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
#include "xmlvm.h"
 
3
#include "org_xmlvm_runtime_XMLVMUtil.h"
 
4
 
 
5
 
 
6
//XMLVM_BEGIN_NATIVE_IMPLEMENTATION
 
7
#include <unistd.h>
 
8
#ifdef __OBJC__
 
9
#ifndef XMLVM_NEW_IOS_API
 
10
#include "org_xmlvm_iphone_NSString.h"
 
11
#else
 
12
#include "org_xmlvm_ios_NSString.h"
 
13
#endif
 
14
#endif
 
15
//XMLVM_END_NATIVE_IMPLEMENTATION
 
16
 
 
17
JAVA_OBJECT org_xmlvm_runtime_XMLVMUtil_getCurrentWorkingDirectory__()
 
18
{
 
19
    //XMLVM_BEGIN_NATIVE[org_xmlvm_runtime_XMLVMUtil_getCurrentWorkingDirectory__]
 
20
#ifdef __OBJC__
 
21
    // Base directory is <App>/Documents/
 
22
    // http://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/FilesandNetworking/FilesandNetworking.html
 
23
    NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
 
24
    NSString* path = [paths objectAtIndex:0];
 
25
    JAVA_OBJECT jpath = fromNSString(path);
 
26
    return jpath;
 
27
#else
 
28
    char buf[1024];
 
29
    char* err = getcwd(buf, sizeof(buf));
 
30
    if (err == NULL) {
 
31
        XMLVM_INTERNAL_ERROR();
 
32
    }
 
33
    return xmlvm_create_java_string(buf);
 
34
#endif
 
35
    //XMLVM_END_NATIVE
 
36
}
 
37