コード例 #1
0
ファイル: rms.c プロジェクト: Sektor/phoneme-qtopia
static MIDPError buildSuiteFilename(pcsl_string* filenameBase, 
                                    const pcsl_string* name, jint extension, 
                                    pcsl_string* pFileName) {

    pcsl_string returnPath = PCSL_STRING_NULL;
    pcsl_string rmsFileName = PCSL_STRING_NULL;

    jsize filenameBaseLen = pcsl_string_length(filenameBase);
    jsize nameLen = pcsl_string_length(name);

    *pFileName = PCSL_STRING_NULL;

    if (nameLen > 0) {
        const pcsl_string* ext;
        jsize extLen;
        int fileNameLen;

        if (MIDP_RMS_IDX_EXT == extension) {
            ext = &IDX_EXTENSION;
            extLen = pcsl_string_length(&IDX_EXTENSION);
        } else if (MIDP_RMS_DB_EXT == extension) {
            ext = &DB_EXTENSION;
            extLen = pcsl_string_length(&DB_EXTENSION);
        } else {
            return BAD_PARAMS;
        }

        /* performance hint: predict buffer capacity */
        fileNameLen = PCSL_STRING_ESCAPED_BUFFER_SIZE(nameLen + extLen);
        pcsl_string_predict_size(&rmsFileName, fileNameLen);

        if (pcsl_esc_attach_string(name, &rmsFileName) !=
                PCSL_STRING_OK ||
                    pcsl_string_append(&rmsFileName, ext) != PCSL_STRING_OK) {
            pcsl_string_free(&rmsFileName);
            return OUT_OF_MEMORY;
        }
    }

    /* performance hint: predict buffer capacity */
    pcsl_string_predict_size(&returnPath, filenameBaseLen + 
                             pcsl_string_length(&rmsFileName));

    if (PCSL_STRING_OK != pcsl_string_append(&returnPath, filenameBase) ||
            PCSL_STRING_OK != pcsl_string_append(&returnPath, &rmsFileName)) {
        pcsl_string_free(&rmsFileName);
        pcsl_string_free(&returnPath);
        return OUT_OF_MEMORY;
    }

    pcsl_string_free(&rmsFileName);
   *pFileName = returnPath;

    return ALL_OK;
}
コード例 #2
0
/**
 * Gets location of the cached resource with specified name
 * for the suite with the specified suiteId.
 *
 * Note that when porting memory for the in/out parameter
 * filename MUST be allocated  using pcsl_mem_malloc().
 * The caller is responsible for freeing the memory associated
 * with filename parameter.
 *
 * @param suiteId       The application suite ID
 * @param storageId     storage ID, INTERNAL_STORAGE_ID for the internal storage
 * @param pResourceName Name of the cached resource
 * @param pFileName     The in/out parameter that contains returned filename
 * @return error code that should be one of the following:
 * <pre>
 *     ALL_OK, OUT_OF_MEMORY, NOT_FOUND,
 *     SUITE_CORRUPTED_ERROR, BAD_PARAMS
 * </pre>
 */
MIDPError
midp_suite_get_cached_resource_filename(SuiteIdType suiteId,
                                        StorageIdType storageId,
                                        const pcsl_string * pResourceName,
                                        pcsl_string * pFileName) {
    const pcsl_string* root = storage_get_root(storageId);
    pcsl_string returnPath = PCSL_STRING_NULL;
    pcsl_string resourceFileName = PCSL_STRING_NULL;
    jint suiteIdLen = GET_SUITE_ID_LEN(suiteId);
    jsize resourceNameLen = pcsl_string_length(pResourceName);

    *pFileName = PCSL_STRING_NULL;

    if (resourceNameLen > 0) {
        /* performance hint: predict buffer capacity */
        int fileNameLen = PCSL_STRING_ESCAPED_BUFFER_SIZE(
            resourceNameLen + pcsl_string_length(&TMP_EXT));
        pcsl_string_predict_size(&resourceFileName, fileNameLen);

        if ( /* Convert any slashes */
            pcsl_esc_attach_string(pResourceName,
                &resourceFileName) != PCSL_STRING_OK ||
            /* Add the extension */
            pcsl_string_append(&resourceFileName, &TMP_EXT) !=
                PCSL_STRING_OK) {
            pcsl_string_free(&resourceFileName);
            return OUT_OF_MEMORY;
        }
    }

    /* performance hint: predict buffer capacity */
    pcsl_string_predict_size(&returnPath, pcsl_string_length(root) +
        suiteIdLen + pcsl_string_length(&resourceFileName));

    if (PCSL_STRING_OK != pcsl_string_append(&returnPath, root) ||
            PCSL_STRING_OK != pcsl_string_append(&returnPath,
                midp_suiteid2pcsl_string(suiteId)) ||
            PCSL_STRING_OK != pcsl_string_append(&returnPath,
                &resourceFileName)) {
        pcsl_string_free(&resourceFileName);
        pcsl_string_free(&returnPath);
        return OUT_OF_MEMORY;
    }

    pcsl_string_free(&resourceFileName);

    *pFileName = returnPath;

    return ALL_OK;
}
コード例 #3
0
/**
 * Builds a full file name using the storage root and MIDlet suite by ID.
 *
 * @param suiteId suite ID
 * @param filename filename without a root path
 * @param sRoot receives full name of the file
 *
 * @return the status: ALL_OK if ok, OUT_OF_MEMORY if out of memory
 */
static MIDPError
get_suite_filename(SuiteIdType suiteId, const pcsl_string* filename,
                   pcsl_string* sRoot) {
  int sRoot_len;
  const pcsl_string* root;

  root = storage_get_root(INTERNAL_STORAGE_ID);

  *sRoot = PCSL_STRING_EMPTY;

  sRoot_len = pcsl_string_length(root)      
            + GET_SUITE_ID_LEN(suiteId)
            + pcsl_string_length(filename);
  pcsl_string_predict_size(sRoot, sRoot_len);

  if (PCSL_STRING_OK == pcsl_string_append(sRoot, root) &&
      PCSL_STRING_OK == pcsl_string_append(sRoot,
          midp_suiteid2pcsl_string(suiteId)) &&
      PCSL_STRING_OK == pcsl_string_append(sRoot, filename)) {
      return ALL_OK;
  } else {
        pcsl_string_free(sRoot);
        *sRoot = PCSL_STRING_NULL;
        return OUT_OF_MEMORY;
  }
}
コード例 #4
0
/**
 * Gets the storage root for a MIDlet suite by ID.
 * Free the data of the string returned with pcsl_string_free().
 *
 * @param suiteId suite ID
 * @param sRoot receives storage root (gets set to NULL in the case of an error)
 *
 * @return status: ALL_OK if success,
 * OUT_OF_MEMORY if out-of-memory
 */
MIDPError
get_suite_storage_root(SuiteIdType suiteId, pcsl_string* sRoot) {
    StorageIdType storageId;
    const pcsl_string* root;
    MIDPError status;

    *sRoot = PCSL_STRING_EMPTY;

    /* get an id of the storage where the suite is located */
    status = midp_suite_get_suite_storage(suiteId, &storageId);
    if (status != ALL_OK) {
        return status;
    }

    root = storage_get_root(storageId);

    pcsl_string_predict_size(sRoot,
        pcsl_string_length(root) + GET_SUITE_ID_LEN(suiteId));

    if (PCSL_STRING_OK == pcsl_string_append(sRoot, root) &&
            PCSL_STRING_OK == pcsl_string_append(sRoot,
                midp_suiteid2pcsl_string(suiteId))) {
        return ALL_OK;
    }

    pcsl_string_free(sRoot);
    *sRoot = PCSL_STRING_NULL;

    return OUT_OF_MEMORY;
}
コード例 #5
0
ファイル: suitestore_intern.c プロジェクト: sfsy1989/j2me
/**
 * Builds a full file name using the storage root and MIDlet suite by ID.
 *
 * @param suiteId suite ID
 * @param filename filename without a root path
 * @param sRoot receives full name of the file
 *
 * @return the status: ALL_OK if ok, OUT_OF_MEMORY if out of memory
 */
static MIDPError
get_suite_filename(SuiteIdType suiteId, const pcsl_string* filename,
                   pcsl_string* sRoot) {
  int sRoot_len;
  const pcsl_string* root;
  StorageIdType storageId;
  MIDPError status;

  /* get an id of the storage where the suite is located */
  status = midp_suite_get_suite_storage(suiteId, &storageId);
  if (status != ALL_OK) {
      return status;
  }

  root = storage_get_root(storageId);

  *sRoot = PCSL_STRING_EMPTY;

  sRoot_len = pcsl_string_length(root)
            + GET_SUITE_ID_LEN(suiteId)
            + pcsl_string_length(filename);
  pcsl_string_predict_size(sRoot, sRoot_len);

  if (PCSL_STRING_OK == pcsl_string_append(sRoot, root) &&
      PCSL_STRING_OK == pcsl_string_append(sRoot,
          midp_suiteid2pcsl_string(suiteId)) &&
      PCSL_STRING_OK == pcsl_string_append(sRoot, filename)) {
      return ALL_OK;
  } else {
        pcsl_string_free(sRoot);
        *sRoot = PCSL_STRING_NULL;
        return OUT_OF_MEMORY;
  }
}
コード例 #6
0
ファイル: suitestore_common.c プロジェクト: sfsy1989/j2me
/**
 * Gets the classpath for the specified MIDlet suite id.
 *
 * Note that memory for the in/out parameter classPath is
 * allocated by the callee. The caller is responsible for
 * freeing it using pcsl_mem_free().
 *
 * @param suiteId   The suite id used to identify the MIDlet suite
 * @param storageId storage ID, INTERNAL_STORAGE_ID for the internal storage
 * @param classPath The in/out parameter that contains returned class path
 * @param extension Extension of the file (
 *
 * @return one of the error codes:
 * <pre>
 *     ALL_OK, OUT_OF_MEMORY
 * </pre>
 */
static MIDPError
get_class_path_impl(SuiteIdType suiteId,
                    jint storageId,
                    pcsl_string * classPath,
                    const pcsl_string * extension) {
    const pcsl_string* root = storage_get_root(storageId);
    pcsl_string path = PCSL_STRING_NULL;
    jint suiteIdLen = GET_SUITE_ID_LEN(suiteId);

    *classPath = PCSL_STRING_NULL;

    /* performance hint: predict buffer capacity */
    pcsl_string_predict_size(&path, pcsl_string_length(root)
                                    + suiteIdLen
                                    + pcsl_string_length(extension));
    if (PCSL_STRING_OK != pcsl_string_append(&path, root) ||
            PCSL_STRING_OK != pcsl_string_append(&path,
                midp_suiteid2pcsl_string(suiteId)) ||
            PCSL_STRING_OK != pcsl_string_append(&path, extension)) {
        pcsl_string_free(&path);
        return OUT_OF_MEMORY;
    }

    *classPath = path;

    return ALL_OK;
}
コード例 #7
0
/**
 * Gets the classpath for the specified MIDlet suite id.
 *
 * Note that memory for the in/out parameter classPath is
 * allocated by the callee. The caller is responsible for
 * freeing it using pcsl_mem_free().
 *
 * @param suiteId   The suite id used to identify the MIDlet suite
 * @param storageId storage ID, INTERNAL_STORAGE_ID for the internal storage
 * @param classPath The in/out parameter that contains returned class path
 * @param extension Extension of the file (
 *
 * @return one of the error codes:
 * <pre>
 *     ALL_OK, OUT_OF_MEMORY
 * </pre>
 */
static MIDPError
get_class_path_impl(ComponentType type,
                    SuiteIdType suiteId,
                    ComponentIdType componentId,
                    jint storageId,
                    pcsl_string * pClassPath,
                    const pcsl_string * pExtension) {
    const pcsl_string* root = storage_get_root(storageId);
    pcsl_string path = PCSL_STRING_NULL;
    jint suiteIdLen = GET_SUITE_ID_LEN(suiteId);
    jint componentIdLen = 0;

#if ENABLE_DYNAMIC_COMPONENTS
    if (type == COMPONENT_DYNAMIC) {
        componentIdLen = GET_COMPONENT_ID_LEN(componentId);
    }
#else
    (void)type;
    (void)componentId;
#endif

    *pClassPath = PCSL_STRING_NULL;

    /* performance hint: predict buffer capacity */
    pcsl_string_predict_size(&path, pcsl_string_length(root)
                                    + suiteIdLen + componentIdLen +
                                    + pcsl_string_length(pExtension));
    if (PCSL_STRING_OK != pcsl_string_append(&path, root) ||
            PCSL_STRING_OK != pcsl_string_append(&path,
                midp_suiteid2pcsl_string(suiteId))) {
        pcsl_string_free(&path);
        return OUT_OF_MEMORY;
    }

#if ENABLE_DYNAMIC_COMPONENTS
    if (type == COMPONENT_DYNAMIC) {
        if (PCSL_STRING_OK != pcsl_string_append(&path,
                midp_componentid2pcsl_string(componentId))) {
            pcsl_string_free(&path);
            return OUT_OF_MEMORY;
        }
    }
#endif

    if (PCSL_STRING_OK != pcsl_string_append(&path, pExtension)) {
        pcsl_string_free(&path);
        return OUT_OF_MEMORY;
    }

    *pClassPath = path;

    return ALL_OK;
}
コード例 #8
0
ファイル: midpStorage.c プロジェクト: sfsy1989/j2me
/*
 * Prefixing the system directory for storage, APP_DIR, with midp_home.
 *
 * @param midp_home file system path to where MIDP is installed
 *
 * @return 0 for success, non-zero for out of memory
 */
int
storageInitialize(char *midp_home) {
    jchar fsep = storageGetFileSeparator();

    if (storageInitDone) {
        /* Already initialized */
        return 0;
    }

    if (PCSL_STRING_OK != pcsl_string_initialize()) {
        REPORT_ERROR(LC_CORE, "Error: cannot initialize string library.\n");
        return -1;
    }

    if(pcsl_file_init() < 0)  {
        REPORT_ERROR(LC_CORE, "Error: out of memory.\n");
        return -1;
    }

    /* set up a path to the internal storage */
    if (PCSL_STRING_OK != pcsl_string_from_chars(midp_home, &sRoot[0])) {
        REPORT_ERROR(LC_CORE, "Error: out of memory.\n");
        storageFinalize();
        return -1;
    }

    /* performance hint: predict buffer capacity */
    pcsl_string_predict_size(&sRoot[0], pcsl_string_length(&sRoot[0]) + 2
                                    + PCSL_STRING_LITERAL_LENGTH(APP_DIR));
    if (PCSL_STRING_OK != pcsl_string_append_char(&sRoot[0], fsep)
     || PCSL_STRING_OK != pcsl_string_append(&sRoot[0], &APP_DIR)
     || PCSL_STRING_OK != pcsl_string_append_char(&sRoot[0], fsep)) {
        REPORT_ERROR(LC_CORE, "Error: out of memory.\n");
        storageFinalize();
        return -1;
    }

    if (0 != initializeConfigRoot(midp_home)) {
        storageFinalize();
        return -1;
    }

    storageInitDone = 1;
    return 0;
}
コード例 #9
0
ファイル: midpStorage.c プロジェクト: sfsy1989/j2me
static int
initializeConfigRoot(char* midp_home) {
    jchar fileSep = storageGetFileSeparator();

    if (PCSL_STRING_OK != pcsl_string_from_chars(midp_home, &configRoot[0])) {
        return -1;
    }

    /* performance hint: predict buffer capacity */
    pcsl_string_predict_size(&configRoot[0],
                            pcsl_string_length(&configRoot[0])
                            + 2 + PCSL_STRING_LITERAL_LENGTH(CONFIG_SUBDIR));

    if (PCSL_STRING_OK != pcsl_string_append_char(&configRoot[0], fileSep)
     || PCSL_STRING_OK != pcsl_string_append(&configRoot[0], &CONFIG_SUBDIR)
     || PCSL_STRING_OK != pcsl_string_append_char(&configRoot[0], fileSep)) {
        pcsl_string_free(&configRoot[0]);
        return -1;
    }

    return 0;
}
コード例 #10
0
/**
 * Reads a line from a manifest file. Compacts continuation lines.<BR>
 * (Allocates memory for this line.)
 *
 * @param mfbuf  pointer to the manifest jchar_buffer; this pointer will move to
 *               the next line
 * @param result pointer to pcsl_string where the new line from manifest
 *               will be stored
 * @return error code
 */
static MIDPError readMfLine(jchar** mfbuf, pcsl_string * result) {
    jchar* lineStart = NULL;
    int is_broken_line = 0;
    jchar* p = NULL;
    int count = 0;
    int i = 0;

    *result = PCSL_STRING_NULL;

    /* will use p to avoid all the *(*mfbuf) stuff and make it more readable */
    p = (*mfbuf);

    if (!(*p)) {
        /* end of jchar_buffer */
        return END_OF_MF;
    }

    /* skip commented out and blank lines */
    while (COMMENTED_OUT(p) || NEW_LINE(p)) {

        while (!NEW_LINE(p)) {
            p++; /* skip commented out line */
        }
        while (NEW_LINE(p)) {
            p++; /* skip new line */
        }

        /* now pointing to the next line */
        if (MF_SPACE(p)) { /* if starting with space */
            while (!NEW_LINE(p)) {
                p++; /* skip the line */
            }
        } /* end of if */

    } /* end of while */

    lineStart = p;

    for (;*p ;) {
        count++;
        p++;
        if (NEW_LINE(p) && !MF_BROKEN_LINE(p)) {
            *p = 0x00; /* cut the line */
            if (*(p+1)) { /* if not end of the buffer */
                p++; /* point to the next line beginning */
                break;
            }
        } else if (MF_BROKEN_LINE(p)) {
            while (!MF_SPACE(p)) { /* look for the space */
                count++;
                p++;
            }
            /* once space found, point to the next character and go ahead */
            count++;
            p++;
            is_broken_line = 1;
            continue;
        } /* end of else */

    } /* end of for */

    /* move mfbuf to point to the next line */
    (*mfbuf) = p;

    pcsl_string_predict_size(result, count);
    if (is_broken_line) {
        i = 0;
        while (*(lineStart+i)) {

            /* here once we have a new line it will be followed by space */
            if (NEW_LINE_1(lineStart+i)) {
                i+=3;
                count-=3;
            } else if (NEW_LINE(lineStart+i)) {
                i+=2;
                count-=2;
            }

            if (PCSL_STRING_OK !=
                pcsl_string_append_char(result, lineStart[i])) {
                pcsl_string_free(result);
                return OUT_OF_MEMORY;
            }
            i++;
        }
    } else {
        if (PCSL_STRING_OK !=
            pcsl_string_convert_from_utf16(lineStart, count, result)) {
            return OUT_OF_MEMORY;
        }
    }

    return ALL_OK;
} /* end of readMfLine */
コード例 #11
0
ファイル: suitestore_rms.c プロジェクト: jiangxilong/yari
/**
 * Gets location of the resource with specified type and name
 * for the suite with the specified suiteId.
 *
 * Note that the implementation of this function MUST allocate the memory
 * for the in/out parameter filename using pcsl_mem_malloc().
 * The caller is responsible for freeing the memory associated
 * with filename parameter.
 *
 * @param suiteId The application suite ID
 * @param storageId storage ID where the RMS will be located
 * NOTE: currently this parameter is ignored due to limitation of our
 * implementation: RMS is always located at the same storage as the suite.
 * @param extension rms extension that can be MIDP_RMS_DB_EXT or
 * MIDP_RMS_IDX_EXT
 * @param pResourceName RMS name
 * @param pFileName The in/out parameter that contains returned filename
 *
 * @return error code that should be one of the following:
 * <pre>
 *     ALL_OK, OUT_OF_MEMORY, NOT_FOUND,
 *     SUITE_CORRUPTED_ERROR, BAD_PARAMS
 * </pre>
 */
MIDPError
midp_suite_get_rms_filename(SuiteIdType suiteId,
                            StorageIdType storageId,
                            jint extension,
                            const pcsl_string* pResourceName,
                            pcsl_string* pFileName) {
    const pcsl_string* root;
    pcsl_string returnPath = PCSL_STRING_NULL;
    pcsl_string rmsFileName = PCSL_STRING_NULL;
    jint suiteIdLen = GET_SUITE_ID_LEN(suiteId);
    jsize resourceNameLen = pcsl_string_length(pResourceName);

    /*
     * IMPL_NOTE: currently we have a limitation that the suite's RMS
     * must be located at the same storage as the midlet suite.
     * See rms.c, rmsdb_get_record_store_space_available() for more details.
     */
    root = storage_get_root(storageId);

    *pFileName = PCSL_STRING_NULL;

    if (resourceNameLen > 0) {
        const pcsl_string* ext;
        jsize extLen;
        int fileNameLen;

        if (MIDP_RMS_IDX_EXT == extension) {
            ext = &IDX_EXTENSION;
            extLen = pcsl_string_length(&IDX_EXTENSION);
        } else if (MIDP_RMS_DB_EXT == extension) {
            ext = &DB_EXTENSION;
            extLen = pcsl_string_length(&DB_EXTENSION);
        } else {
            return BAD_PARAMS;
        }

        /* performance hint: predict buffer capacity */
        fileNameLen = PCSL_STRING_ESCAPED_BUFFER_SIZE(resourceNameLen + extLen);
        pcsl_string_predict_size(&rmsFileName, fileNameLen);

        if (pcsl_string_append_escaped_ascii(&rmsFileName, pResourceName) !=
                PCSL_STRING_OK ||
                    pcsl_string_append(&rmsFileName, ext) != PCSL_STRING_OK) {
            pcsl_string_free(&rmsFileName);
            return OUT_OF_MEMORY;
        }
    }

    /* performance hint: predict buffer capacity */
    pcsl_string_predict_size(&returnPath, pcsl_string_length(root) +
        suiteIdLen + pcsl_string_length(&rmsFileName));

    if (PCSL_STRING_OK != pcsl_string_append(&returnPath, root) ||
            PCSL_STRING_OK != pcsl_string_append(&returnPath,
                midp_suiteid2pcsl_string(suiteId)) ||
            PCSL_STRING_OK != pcsl_string_append(&returnPath, &rmsFileName)) {
        pcsl_string_free(&rmsFileName);
        pcsl_string_free(&returnPath);
        return OUT_OF_MEMORY;
    }

    pcsl_string_free(&rmsFileName);

    *pFileName = returnPath;

    return ALL_OK;
}
コード例 #12
0
ファイル: fcCleanup.c プロジェクト: sfsy1989/j2me
/**
 * This helper function deletes the specified directory and all
 * its contents.
 *
 * @param pDirName the directory to delete
 */
void do_cleanup(const pcsl_string* pDirName)
{
    pcsl_string name1 = PCSL_STRING_NULL;
    pcsl_string * pSubDir = &name1;
    pcsl_string name2 = PCSL_STRING_NULL;
    pcsl_string * pDirEntry = &name2;
    pcsl_string * tmp;
    javacall_handle listHandle;
    int nestLevel = 0;
    int pathLen;
    javacall_utf16 * fileName = NULL;
    int fileNameLen = 0;
    pcsl_string_status status;
    javacall_result res;
    int finish = 0;
    jchar sep = javacall_get_file_separator();

    // initialize current directory
    if (PCSL_STRING_OK != pcsl_string_dup(pDirName, pSubDir)) {
        return;
    }

    for ( ; ; ) {
        // open upper-level directory for listing
        GET_PCSL_STRING_DATA_AND_LENGTH(pSubDir)
        if (PCSL_STRING_PARAMETER_ERROR(pSubDir)) {
            listHandle = NULL;
        } else {
            listHandle = javacall_dir_open(pSubDir_data, pSubDir_len);
        }
        RELEASE_PCSL_STRING_DATA_AND_LENGTH
        if (NULL == listHandle) {
            pcsl_string_free(pSubDir);
            return;
        }

        // get the first entry in the current directory
        fileName = javacall_dir_get_next(listHandle, &fileNameLen);

        while (NULL != fileName) {
            // compose full path for the directory entry
            if (PCSL_STRING_OK != pcsl_string_dup(pSubDir, pDirEntry)) {
                javacall_dir_close(listHandle);
                pcsl_string_free(pSubDir);
                return;
            }
            pcsl_string_predict_size(pDirEntry, pcsl_string_length(pDirEntry) + 1 + fileNameLen);
            if (PCSL_STRING_OK != pcsl_string_append_char(pDirEntry, sep)
             || PCSL_STRING_OK != pcsl_string_append_buf(pDirEntry, fileName, fileNameLen)) {
                javacall_dir_close(listHandle);
                pcsl_string_free(pSubDir);
                pcsl_string_free(pDirEntry);
                return;
            }

            // check if directory entry is a subdirectory
            GET_PCSL_STRING_DATA_AND_LENGTH(pDirEntry)
            if (PCSL_STRING_PARAMETER_ERROR(pDirEntry)) {
                finish = 1;
            } else {
                res = javacall_fileconnection_dir_exists(pDirEntry_data, pDirEntry_len);
            }
            RELEASE_PCSL_STRING_DATA_AND_LENGTH
            if (finish) {
                javacall_dir_close(listHandle);
                pcsl_string_free(pSubDir);
                pcsl_string_free(pDirEntry);
                return;
            }
            if (JAVACALL_OK == res) {
                // found subdirectory, open it for listing
                javacall_dir_close(listHandle);
                pcsl_string_free(pSubDir);
                tmp = pDirEntry;
                pDirEntry = pSubDir;
                pSubDir = tmp;
                GET_PCSL_STRING_DATA_AND_LENGTH(pSubDir)
                if (PCSL_STRING_PARAMETER_ERROR(pSubDir)) {
                    listHandle = NULL;
                } else {
                    listHandle = javacall_dir_open(pSubDir_data, pSubDir_len);
                }
                RELEASE_PCSL_STRING_DATA_AND_LENGTH
                if (NULL == listHandle) {
                    pcsl_string_free(pSubDir);
                    return;
                }
                nestLevel++;
            } else {
                // found regular file, simply remove it
                GET_PCSL_STRING_DATA_AND_LENGTH(pDirEntry)
                if (PCSL_STRING_PARAMETER_ERROR(pDirEntry)) {
                    res = JAVACALL_FAIL;
                } else {
                    // ensure that the file is not read-only
                    javacall_fileconnection_set_writable(pDirEntry_data, pDirEntry_len, JAVACALL_TRUE);
                    res = javacall_file_delete(pDirEntry_data, pDirEntry_len);
                }
                RELEASE_PCSL_STRING_DATA_AND_LENGTH
                pcsl_string_free(pDirEntry);
                if (JAVACALL_OK != res) {
                    javacall_dir_close(listHandle);
                    pcsl_string_free(pSubDir);
                    return;
                }
            }
            // iterate through the current directory
            fileName = javacall_dir_get_next(listHandle, &fileNameLen);
        }