开发者

Does Android support setjmp/longjmp, access, chdir, getcwd?

开发者 https://www.devze.com 2023-01-06 04:01 出处:网络
I\'m pretty new to Android development and I\'d like to know whether Android supports the above mentioned featur开发者_JAVA百科es which are there in C.

I'm pretty new to Android development and I'd like to know whether Android supports the above mentioned featur开发者_JAVA百科es which are there in C.

Thanks in advance.


These functions are available when coding in native C via the Android NDK. The NDK has a standard C library which includes these functions.

  • getcwd(buf, size) functions a little differently from the Unix standard, in that it does not allocate memory if buf is NULL. You should preallocate the buffer. http://linux.die.net/man/2/chdir
  • chdir(path) functions as expected, although its use is limited by the fact that Android (stupidly) does not provide a function to retrieve application context-relevant information such as the path to external storage (although you can retrieve the path via JNI calls.) http://linux.die.net/man/3/getcwd
  • I cannot comment on the functionality in Android of longjmp etc.

If you prefer to remain in the Android Java environment, you will find that there is no concept of current working directory, so chdir() and getcwd() are obsoleted. Instead, the system makes available a set of functions for discovering internal and external storage paths (see http://developer.android.com/guide/topics/data/data-storage.html). Also typical uses of setjmp()/longjmp() can be generally covered by Java exceptions or other mechanisms.


Not sure whether it has those integrated into the language, but if you really need to access any Native C methods, you could use JNI (Java Native Interface), which will allow you to run Native C code.

Also, take a look at the Exception and File classes - they may give you similar functionality.


You shouldn't need them. Apps for Android are generally done in Java. setjmp/longjmp is a C/C++ thing (yes, I programmed in it for a while and still hate it :-)

0

精彩评论

暂无评论...
验证码 换一张
取 消