|
I have a binary file of size 3GB. I want to reduce the size using some coding in C to write another binary file.
Please suggest/provide a way to write compact binary file.
TO read this file i need to use C#.
Thanks,
Sachin
|
|
|
|
|
WinZip(3GB_Filename, 2GB_Filename); ?
Seriously, it depends on what is contained in the 3GB binary file. Is it even compressible?
If it contains lots of NULLS, for example, change the NULL bytes to a single NULL followed by a count of how many there are. A string of 10 NULLS would turn into a single NULL and a byte with the number 10 in it, saving 8 bytes.
Reading the file in, you would simply reverse the process.
1,2,3,4,5,0,0,0,0,0,0,0,0,0,0,1,2,3,a,b,c,0,0,0,0,d,e,0,f,ff
(30 bytes)
Becomes
1,2,3,4,5,0,a,1,2,3,a,b,c,0,4,d,e,0,1,f,ff
(21 bytes)
Alternatively, implement one of the Open Source Zip and Unzip routines in your C and C# code, as appropriate.
Gary
|
|
|
|
|
check this library.
http://zlib.net/[^]
use following function from library for compress binary file.
deflateInit
deflate
deflateEnd
|
|
|
|
|
I've used (libbzip2[^]) in the past with some success at shrinking certain types of binary file. Hopefully there's some repetition in it or whatever you try isn't going to be able to do much to shrink it.
Cheers,
Ash
|
|
|
|
|
|
fatal error LNK1104: cannot open file "hid.lib"
please give me any solution.
|
|
|
|
|
Ruchira Patel wrote: fatal error LNK1104: cannot open file "hid.lib"
Check if the file mentioned in the error message("hid.lib") is present or not.
If the file is in some 3rd party libraries installed in system, give the correct path in "Additional include directories" option of your project settings.
--
"Programming is an art that fights back!"
|
|
|
|
|
rp_suman wrote: give the correct path in "Additional include directories"
This is a library file, not an include file. The folder should be mentionned in "Additional Library Directories".
|
|
|
|
|
i've actually meant library path only.. thanks for the correction..
regards
--
"Programming is an art that fights back!"
|
|
|
|
|
Make sure this file exist on your system and can be found by the compiler (it should either be in the project directory or located in one of the "Additional Library Directory" (project settings -> "Linker" -> "General" -> "Additional Library Directory").
|
|
|
|
|
Ruchira Patel wrote: please give me any solution.
See here.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Hi,
i am working on a simple application that needs to be updated frequently, do you have an an article that discusses how an application downloads the update then install it. Like an anti virus, it downloads the update definitions then install it on its own.
lets say its an application that collects updates from a common share-point.
lets not focus on the install part, what we want to focus is on the connection and download part..
and what are the common protocol and ports used for connection?
i got some good hint from Simon Ellis's article, An AutoUpdate Trick An AutoUpdate Trick[^], but i still can't find where is the download part,
any help or guide will be much appreciated, thanks in advance
|
|
|
|
|
loid grey manuel wrote: lets say its an application that collects updates from a common share-point.
I used a repository with version information, the application checks what needs to be downloaded. After successful download, checksum verification and unpacking the updater checks modification time on a per file basis, to decide which binary really needs to be replaced. If you plan to update multiple files, make sure they will be replaced together (to avoid dependency issues).
To my knowledge there is no simple automatic update mechanism on Windows, you probably need an extra executable for: stopping your application, replacing files and restarting you application again (all should be UAC compatible for Vista/Win7).
loid grey manuel wrote: and what are the common protocol and ports used for connection?
I did all network communication via HTTP, this means repository and downloads are on a web server.
Hope it helps.
|
|
|
|
|
Yup, it was a good hint for me, I've started reading books regarding your suggestions. since I don't have a personally owned database repository at least yet, and i only use free web hosting sites to store some of my files that i needed to access often.
thanks for the headstart, appreciate it.
but if you have a sample code or application for me to review the code, it would be easier.
thanks again,
|
|
|
|
|
If I use RegLoadKey() to load registry data from a hive, does the newly loaded data exist at the same time as the previously loaded data?
OR, does the previous data disappear, and only the new data exists under the predefined key?
For example, if I want to load information for a single COM server under HKEY_CLASSES_ROOT, will everything that was previously under that key still be there?
|
|
|
|
|
Richard Andrew x64 wrote: For example, if I want to load information for a single COM server under HKEY_CLASSES_ROOT, will everything that was previously under that key still be there?
Yes, unless you overwrite or delete it.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Thanks, that solves a big problem.
|
|
|
|
|
I'm not sure if I've given the proper label to my issue, but I have upgraded to the new version of MinGW and am now having trouble compiling my code in Codeblocks. The program runs fine when executed from Codeblocks, but once I try to run it from windows I get an error stating that I need a certain dll file for it to run.
I found on a forum a linker option that has covered one of the required dlls but not all of them (-static-libgcc)
What linker options can I use to get rid of all these dependancies, I don't care how large it makes my exe; I think its easier to live with a large exe than having to package dlls with my project.
I appreciate any advise anyone has to offer.
|
|
|
|
|
It depends what the DLL is. If it's one you've got the source for rebuild it as a static library (archive in MinGW terms) and link against that instead. If it's not then it might be time to look for a replacement or get rid of the code that uses that DLL.
Cheers,
Ash
|
|
|
|
|
I have a string object called str. The content within is "Line1Line1\nLine2Line2\n". I can find the positions of '\n's using char array and use them like this str[10], but how to do this with string object. What is the function for this? I mean I know about string.find() and use it like this:
int n = 0;
n = str.find("\n");
but what if I want the second '\n'?
modified on Thursday, October 21, 2010 3:28 PM
|
|
|
|
|
What is "string object"? CString? std::string?
If it is CString, then as you can see in the documentation of CString::Find[^], you can specify it the starting character it will search from, so when n contains your first '\n', just feed find with n+1...
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Leela: Fry, you're wasting your life sitting in front of that TV. You need to get out and see the real world.
Fry: But this is HDTV. It's got better resolution than the real world <
|
|
|
|
|
TCPMem wrote: but what if I want the second '\n'?
Use the (incremented) last position as start for the next find():
std::string str = "Line1Line1\nLine2Line2\n";
for (size_t pos = 0; pos != str.npos; pos = str.find('\n', ++pos))
std::cout << str.substr(pos);
cheers,
AR
When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)
|
|
|
|
|
I need to pass an array into a procedure and return a string. The problem is the array could be 1, 2, 3 or 4 character strings.
I am stuck as how to do it, see typical arrays below.
char *OPTIONS_ENUMS[4] = {
"OPT_1",
"OPT_2",
"OPT_3",
"OPT_4"};
char *OPTIONS2_ENUMS[4] = {
"OPT_1",
"OPT_4"};
char* GetOptions(short nStatus, char* szOptions)
{
int i, nOptions;
nOptions = sizeof(ssmStatusOptions);
for(i=0; i < nOptions; i++)
{
if(nStatus == 0)
{
if(strcmp(szOptions[i], "NULL") == 0)
{
return "NULL";
}
else if(strcmp(szOptions[i], "ITEM1") == 0)
{
return "ITEM1";
}
else if(strcmp(szOptions[i], "NO_DATA") == 0)
{
return "NO_DATA";
}
}
else if(nStatus == 1)
{
if(strcmp(szOptions[i], "OK") == 0)
{
return "OK";
}
else if(strcmp(szOptions[i], "ITEM2") == 0)
{
return "ITEM2";
}
else if(strcmp(szOptions[i], "NO_DATA") == 0)
{
return "NO_DATA";
}
}
}
} How to call the procedure
e.g.
GetOptions(1, OPTIONS2_ENUMS);
where OPTIONS2_ENUMS is
char *OPTIONS_ENUMS[4] = {
"OPT_1",
"OPT_2",
"OPT_3",
"OPT_4"};
I need to know how many elements in the array and how to pass over the array. Its a c code project.
Many thanks.
|
|
|
|
|
You could either specify the array size to the function as an additional parameter, or you could terminate your array with NULL and in the function iterate until you get a NULL.
Btw, shouldn't this:
Andy202 wrote: char* GetOptions(short nStatus, char* szOptions)
be instead this:
char* GetOptions(short nStatus, char **szOptions) ?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Leela: Fry, you're wasting your life sitting in front of that TV. You need to get out and see the real world.
Fry: But this is HDTV. It's got better resolution than the real world <
|
|
|
|
|
Thanks for your suggestion. But are they anyway I can find out the number of elements in an array like this:-
char *OPTIONS_ENUMS[4] = {"OPT_1","OPT_2","OPT_3","OPT_4"};
for(int j = 0; j < 100; j++)
{
if(OPTIONS_ENUMS[j] == NULL)
return j;
}
|
|
|
|
|