/** * Approximation of remaining RMS space in storage for a suite. * * Usage Warning: This may be a slow operation if * the platform has to look at the size of each file * stored in the MIDP memory space and include its size * in the total. * * @param handle handle to record store storage * @param pStorageId storage id of the suite * * @return the approximate space available to grow the * record store in bytes. */ long rmsdb_get_record_store_space_available(int handle, int pStorageId) { /* Storage may have more then 2Gb space available so use 64-bit type */ jlong availSpace; long availSpaceUpTo2Gb; char* pszError; StorageIdType storageId; /* * IMPL_NOTE: for security reasons we introduce a limitation that the * suite's RMS must be located at the internal storage. * Note that the public RecordStore API doesn't support * a storageId parameter. * There is a plan to get rid of such limitation by introducing a * function that will return a storage ID by the suite ID and RMS name. */ storageId = pStorageId; availSpace = midp_file_cache_available_space(&pszError, handle, storageId); /* * Public RecordStore API uses Java int type for the available space * so here we trim the real space to 2Gb limit. */ availSpaceUpTo2Gb = (availSpace <= LONG_MAX) ? availSpace : LONG_MAX; return availSpaceUpTo2Gb; }
/** * Approximation of remaining RMS space in storage for a suite. * * Usage Warning: This may be a slow operation if * the platform has to look at the size of each file * stored in the MIDP memory space and include its size * in the total. * * @param handle handle to record store storage * @param id ID of the suite * * @return the approximate space available to grow the * record store in bytes. */ long rmsdb_get_record_store_space_available(int handle, SuiteIdType id) { /* Storage may have more then 2Gb space available so use 64-bit type */ jlong availSpace; long availSpaceUpTo2Gb; char* pszError; StorageIdType storageId; MIDPError status; (void)id; /* Avoid compiler warnings */ /* * IMPL_NOTE: here we introduce a limitation that the suite's RMS * must be located at the same storage as the midlet suite. * This is done because the public RecordStore API doesn't support * a storageId parameter. * There is a plan to get rid of such limitation by introducing a * function that will return a storage ID by the suite ID and RMS name. */ status = midp_suite_get_suite_storage(id, &storageId); if (status != ALL_OK) { return 0; /* Error: report that no space is available */ } availSpace = midp_file_cache_available_space(&pszError, handle, storageId); /* * Public RecordStore API uses Java int type for the available space * so here we trim the real space to 2Gb limit. */ availSpaceUpTo2Gb = (availSpace <= LONG_MAX) ? availSpace : LONG_MAX; return availSpaceUpTo2Gb; }