CodeModuleManager cannot allocate space for the module - blackberry

I am trying to write an app that will download and install cod files.
I have the line:
CodeModuleManager.createNewModule(codData.length, codData, codData.length);
which is expected to return a module handle (which is an int). However, it returns 0 that means space cannot be allocated for the module to be intalled. I searched a bit but coulndt really find any info about what may be causing this. Any ideas ?

I found the solution:
I used the COD files inside the deliverables/web directory
When the COD file is above some size it is partitioned into 2 (or more) cod files. In my case there were two COD files. One was named abc.cod and the other one was abc-1.cod. You need to have both cod files in order to make the installation. (which was the real problem)
I noticed that in the deliverables/standard folder there is only 1 cod file which is probably the case that it is not splitted into 2 parts and, thus, the CodeModuleManager is not able to allocate space for it as a whole (thus partitioning is necessary afterall)
However, even after this you can encounter problems such as the icon of your application getting disappeared when you overwrite cod files (ie. when you try to update your app which already exists).
I found it more convenient to work with the .jad file. Just set up the right mime types in your directory and put the jad and cod files in there. Then open your jadfile using the browser and your app should be automatically and smoothly installed/updated by the OS itself.
Hope this proves helpful for someone else

Related

Is there a way to find file type?

I would like to get the type of a file without using the extension, is there a way to use the metadata of a file to distinguish if it is a video file or if it isnt?
I have tried using extensions but I find searching each file extension and comparing it with a list of extensions is quite time consuming.
Yes it is possible to determine file type without using the file extension. You can do this by reading the file header also sometimes referred as file signature which occupies first few bytes of the file.
How many bytes do file header/signature occupy? This depends from file type to file type. So you should check the internet for more detailed information about the file header/signature for specific file type you want to identify.
You can find list of some more popular signatures List of file signatures - Wikipedia
PS: Most program stopped relying only on file signatures for determining file way back when first Windows came out. The main reason for this was the fact that since in the beginning file extensions were limited to three character length (limit of the old file systems like old FAT8 or FAT16) world quickly ran out of possible file extensions so multiple programs began to use same file extensions but used completely different file types. So by storing file header/signature at the beginning of the file you would no longer be limited by this file system limitation.

Convert a filetype to its original state

How can I change a file type?
A year ago I wrote a few articles that should be viewed in any text type of program. however, I recently opened them and they are viewed in symbols and alphanumeric characters. In linux os, the 'file' is now in an archived folder type that contains .xml files. in windows os it is 'file' as type of file. it has no extension.
Is there any way to recover the original readable alpha-numeric information in these files?
My preference would be to salvage the original information than redo.
First off the extension doesn't actually mean anything for the information of the file, it's only purpose is as a hint to the OS for deciding which application should be used in opening the file. You can prove this by renaming something like an exe to have a txt extension which will then open in notepad as a lot of seemingly random characters; renaming it back to exe will allow it to run again.
Based on your description the files you mention are some form of binary file, the bad news with that is you need to know either what application was used to create the file in order to be able to open it or what the original file extension was (which would be a hint to the former).
If you don't know either of those pieces of information you can of course use trial and error by guessing what extension it might be, renaming it, then opening it with the associated application and seeing if it worked.

Unconcatenating files

I have a corrupted 7-zip archive that I am extracting manually using the method outlined by Igor Pavlov at this link. An intermediate result is a large file that is a bunch of files cat'ed together that must be separated manually. I understand that some file formats will need to be extracted manually by a human using discretion (text files, etc.) but many file formats encode the size of the file as part of the file itself (e.g. .zip). Furthermore, some files can be parsed and their size can be deduced with just a little information about the file format (e.g. .pdf). Let's say the large file consists of the following files concatenated together:
Key: <filename>(<contents>)
badfile(aaaaaaaaaaabbbbbbbbbcccccccdddddddd) -> zip1.zip(aaaaaaaaaaa)
badfile2(bbbbbbbbbcccccccdddddddd)
I am looking for a program that I can run on a large file (call it badfile) that can determine the type and size of the first logical file (let's say it's a .zip file) contained within and create a new file to hold the contents (e.g. zip1.zip since filenames are lost) and chop the file off the front of badfile. This would allow me to run the program in a loop to extract files with known types and/or pause and let the user handle the difficult cases. Does such a program exist? I know that the *nix command file(1) will do a lot of the work here, but there would be a lot of effort in encoding rules for sizing files (e.g. .pdf) that I would prefer to not duplicate.
I believe this question should be closed due to being off topic as it asks to find existing programs to solve the problem, but open bounty prevents close vote. However.
Does such a program exist?
Yes they exist is and are called data carving tools.
Some commom ones include scalpel and foremost and PhotoRec
A list of other tools is avaliable here

Issue with the size of the .cod file

I need to add more png images to my app. When the size of the .cod file crosses 5mb it throws a runtime exception, and I cannot figure why, even with a debugger. If I remove some images I can run the app. I am using BlackBerry OS 4.7 with the storm. Later OS versions also have the same issue.
Hi Arhimed thanks for your
suggestion.How to do lazy resource
loading? When I am taking all the
images before main method I move the
images to SDCard.But it is throwing
same runtimeexception and I cannot
compile it.
Under the "lazy resource loading" I mean you could host your images somewhere in the internet. So on the first app start, being under a splash screen, you would download them to SDCard (or to Device Memory if Device Memory is big enough - it is fully up to you where to store the images). On a slow connection it could take minutes, so you definitely need to inform users about what is going on, so they don't think the app has hung.
Yes, Use OTA in Following command on Application folder.
cd application dir.....
ren appName.cod *.zip // this will divided one cod file to multiple part it.
and now you can extract this zip file on specific folder and also add it's .jad file

keep rsync from removing unfinished source files

I have two machines, speed and mass. speed has a fast Internet connection and is running a crawler which downloads a lot of files to disk. mass has a lot of disk space. I want to move the files from speed to mass after they're done downloading. Ideally, I'd just run:
$ rsync --remove-source-files speed:/var/crawldir .
but I worry that rsync will unlink a source file that hasn't finished downloading yet. (I looked at the source code and I didn't see anything protecting against this.) Any suggestions?
It seems to me the problem is transferring a file before it's complete, not that you're deleting it.
If this is Linux, it's possible for a file to be open by process A and process B can unlink the file. There's no error, but of course A is wasting its time. Therefore, the fact that rsync deletes the source file is not a problem.
The problem is rsync deletes the source file only after it's copied, and if it's still being written to disk you'll have a partial file.
How about this: Mount mass as a remote file system (NFS would work) in speed. Then just web-crawl the files directly.
How much control do you have over the download process? If you roll your own, you can have the file being downloaded go to a temp directory or have a temporary name until it's finished downloading, and then mv it to the correct name when it's done. If you're using third party software, then you don't have as much control, but you still might be able to do the temp directory thing.
Rsync can exclude files matching certain patters. Even if you can't modify it to make it download files to a temporary directory, maybe it has a convention of naming the files differently during download (for example: foo.downloading while downloading for a file named foo) and you can use this property to exclude files which are still being downloaded from being copied.
If you have control over the crawling process, or it has predictable output, the above solutions (storing in a tempfile until finished, then mv'ing to the completed-downloads place, or ignoring files with a '.downloading' kind of name) might work. If all of that is beyond your control, you can make sure that the file is not opened by any process by doing 'lsof $filename' and checking if there's a result. Clearly if no one has the file open, it's safe to move it over.

Resources