1

I have a config.txt file. The file is not compressed during the apk build using the nocompress extension="txt" option. Then I'm openning in my java code asset manager and passing it to the native function. Finally I'm opening a File* using the below code. The problem is that when calling fgets(line, 32, file) - where line is char * - the content of line is not what is the first line of the file.

AAssetManager* mgr = AAssetManager_fromJava(env, assetManager);
if(NULL == mgr) return -1;
AAsset* asset = AAssetManager_open(mgr, "config.txt", AASSET_MODE_UNKNOWN);
if (NULL == asset) {
    return -1;
}
off_t start, length;
int fd = AAsset_openFileDescriptor(asset, &start, &length);
if (fd < 0)
    return -1;
 FILE * file = fdopen(fd, "r");
nmnir
  • 568
  • 1
  • 10
  • 24

1 Answers1

0

As you can see in https://code.google.com/p/java-ide-droid/source/browse/trunk/jni/aapt/jni/Package.cpp (search for "static const char* kNoCompressExt" ) txt is not in the exclude list and may be compressed! Actually this should lead to fd beeing smaller than zero.

Sergey K.
  • 24,894
  • 13
  • 106
  • 174
PhilLab
  • 4,777
  • 1
  • 25
  • 77