|
Thanks for the hint, Peter, but when I added the following, the program crashes. I assume I'm missing something.
IVssBackupComponents *pReq;
VSS_ID snapID;
PWSTR wszExposed;
CLSIDFromString(L"{3c8b7455-4f04-4ead-b666-578ddb608138}", &snapID);
hres = pReq->ExposeSnapshot(snapID, NULL, VSS_VOLSNAP_ATTR_EXPOSED_LOCALLY, L"x:", &wszExposed);
I am using vshadow -wait c: on a test machine to generate the snapshot, so I'm not sure if that will cause any conflicts. I'll go ahead and tinker with HoboCopy and toss it in there to see what happens.
Thanks.
|
|
|
|
|
Doing more research on ExposeSnapshot(), aside from my above implementation being incorrect (don't need the {}'s), I don't think it works on XP. The snapshot needs to be created with a specific context property, either VSS_CTX_APP_ROLLBACK or VSS_CTX_NAS_ROLLBACK. Sadly, XP does not support setting a different context other than the default, VSS_CTX_BACKUP. So, it seems that using ExposeSnapshot is not a viable option as it needs to work on XP and Server 2003.
Thanks, though. I learned quite a bit more about VSS by looking through this.
|
|
|
|
|
I want to read files into memory in C. But the fread function needs the buffer where files from disk will be read to. How do I know the size of the file so that I can allocate the required memory size with malloc() before I give it to fread as an argument? I don't want the program to assume any file size. Is there any C library function to give
me the size of the file been opened so that I can allocate the needed memory size? Please help.
|
|
|
|
|
|
But I think GetFileSizeEx is windows specific that requires a HANDLE to a file. I don't want it to be based on Windows.
|
|
|
|
|
Ok so you should use the functions of CPallini. They should work.
Greetings
Covean
|
|
|
|
|
YOu may use ftell [^] and fseek [^]for the purpose.
Or you may use filelenght [^] (however you should pass a file descriptor to filelenght ).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Thanks. The idea I'm getting from you is to seek to the end of the file and use ftell() to give me the size. I believe that's what you are saying.
|
|
|
|
|
You can do that, but that impliesm opening the file for (at least) read access. You could also use the _stat function.
|
|
|
|
|
Never met this _stat function before. Which header file is its prototype and how do I use it?
|
|
|
|
|
|
Based on what you told me I wrote the following function and it's working.
long get_file_size(FILE* fp)
{
fseek(fp, 0L, SEEK_END);
return (ftell(fp));
}
I checked the return value and compared with the size of a file read. It was correct. Thanxxx!
|
|
|
|
|
You are welcome.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Dan_K wrote:
long get_file_size(FILE* fp)
{
fseek(fp, 0L, SEEK_END);
return (ftell(fp));
}
It was years ago i used these but didn't fseek() return the bytes, so:
long get_file_size(FILE* fp)
return (fseek(fp, 0L, SEEK_END));
Does the same? And wasn't Ftell() not enough?
long get_file_size(FILE* fp)
return (ftell(fp));
So this one does the same? Or I'm getting old?
Rozis
|
|
|
|
|
Small FYI. If you are going to read a file entirely into memory, buffered I/O (i.e. fopen()) is redundant.) If you want to stay with the CRT, you are better off using the _open()/_filelength()/_read() functions. (I just use the raw Win32 calls, but all my work is highly Windows specific.)
|
|
|
|
|
Hi All,
Can anyone provide me example for using zend library in vc++. I have to pass c++ object to php script is my requirement.
looking ahead for reply.
Thanks A Ton
Ash_VCPP
walking over water is just knowing where the stones are.....
|
|
|
|
|
Hi,
there is a tool to generate wrappers to call C/C++ from PHP and other script languages called SWIG ( see: http://www.swig.org[^] ). I've used it a few times to generate wrappers for perl.
Hope this helps.
Frank
|
|
|
|
|
Hi Frank,
Can i use Zend library to do the same because i have done some rnd on it. so if u know anything about it yhen please let me know.
Thanks A Ton
Ash_VCPP
walking over water is just knowing where the stones are.....
|
|
|
|
|
Hi,
Now I use a driver (first part of the code) - no changes possible.
I have to use something like a message processing and because I'm unable to use an array of the internal buffers of the driver -> I use more then 10 function with the same code.
here is my code
I would like to use a vector of messages (message0, message1 ..).
any other ideea is welcome of grouping these data types.
thanks
<pre>// Gateway_array.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
typedef struct
{
unsigned char signal7 : 8;
unsigned char signal6 : 8;
unsigned char signal5 : 8;
unsigned char signal4 : 8;
unsigned char signal3 : 8;
unsigned char signal2 : 8;
unsigned char signal1 : 8;
unsigned char signal0 : 8;
} msgType0;
typedef union
{
unsigned char _c[8];
msgType0 msg0_0;
} buf0;
buf0 message0;
typedef struct
{
unsigned char signal7 : 8;
unsigned char signal6 : 8;
unsigned char signal5 : 8;
unsigned char signal4 : 8;
unsigned char signal3 : 8;
unsigned char signal2 : 8;
unsigned char signal1 : 8;
unsigned char signal0 : 8;
} msgType1;
typedef union
{
unsigned char _c[8];
msgType1 msg0_1;
} buf1;
buf1 message1;
/// ................................
/// UP is the Driver .. No changes possible
// X 8 times
typedef struct
{
unsigned char signal7 : 8;
unsigned char signal6 : 8;
unsigned char signal5 : 8;
unsigned char signal4 : 8;
unsigned char signal3 : 8;
unsigned char signal2 : 8;
unsigned char signal1 : 8;
unsigned char signal0 : 8;
} msgType;
typedef union
{
unsigned char _c[8];
msgType msg;
} type_array;
type_array Vector[2]; // i would like to use a vector like this one
int main(int argc, char* argv[])
{
Vector[0] = message0; //error when using it
return 0;
}
</pre>
|
|
|
|
|
Why don't you define type_array as union of {buf1 , .., buf8 }?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi
with a union like this doesn't work either.
I get ..cannont convert buf0 to unsigned char.
typedef union
{
buf0 msg0;
buf1 msg1;
} type_Array;
type_Array Vector[]={message0 , message1};
if i put like this, works:
unsigned char x1;
unsigned char x2;
type_Array Vector[]={x1, x2};
//(this doesn't seem to be logic i should have here a vector of 8 unsigned chars)
so, the problem is
the compiler see message0 of type buf0, somehow cannot use union definition.
msgType0 and msgType1 are user defined types.
|
|
|
|
|
Why you want to assign a unsigned char to a msgType0 ? It looks more reasonable something like
msgType0 msg;
unsigned char x = 0x20;
msg.signal0 = x;
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
yes, true
my problem is I cannot build the array with this code:
/// Driver
typedef struct
{
unsigned char signal7 : 8;
unsigned char signal6 : 8;
unsigned char signal5 : 8;
unsigned char signal4 : 8;
unsigned char signal3 : 8;
unsigned char signal2 : 8;
unsigned char signal1 : 8;
unsigned char signal0 : 8;
} msgType0;
typedef union
{
unsigned char _c[8];
msgType0 msg0_0;
} buf0;
buf0 message0;
typedef struct
{
unsigned char signal7 : 8;
unsigned char signal6 : 8;
unsigned char signal5 : 8;
unsigned char signal4 : 8;
unsigned char signal3 : 8;
unsigned char signal2 : 8;
unsigned char signal1 : 8;
unsigned char signal0 : 8;
} msgType1;
typedef union
{
unsigned char _c[8];
msgType1 msg0_1;
} buf1;
buf1 message1;
/// ................................
/// UP is the Driver .. No changed possible
// X 8 times
// seems logic to work with this code
typedef union
{
buf0 msg0;
buf1 msg1;
} type_Array;
type_Array Vector[]={message0 , message1};
so, I want to build an array of message0, message1....
not other data.
|
|
|
|
|
hi
the ideea was ok. my sintax was not
this code is ok:
// diff types array.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
typedef struct
{
unsigned char signal7 : 8;
unsigned char signal6 : 8;
unsigned char signal5 : 8;
unsigned char signal4 : 8;
unsigned char signal3 : 8;
unsigned char signal2 : 8;
unsigned char signal1 : 8;
unsigned char signal0 : 8;
} msgType0;
typedef union
{
unsigned char _c[8];
msgType0 msg0_0;
} buf0;
buf0 message0;
typedef struct
{
unsigned char signal7 : 8;
unsigned char signal6 : 8;
unsigned char signal5 : 8;
unsigned char signal4 : 8;
unsigned char signal3 : 8;
unsigned char signal2 : 8;
unsigned char signal1 : 8;
unsigned char signal0 : 8;
} msgType1;
typedef union
{
unsigned char _c[8];
msgType1 msg0_1;
} buf1;
buf1 message1;
/// ................................
/// UP is the Driver .. No changed possible
// X 8 times
int main(int argc, char* argv[])
{
printf("Hello World!\n");
typedef union
{
buf0 msg0;
buf1 msg1;
} type_Array;
type_Array X1;
type_Array X2;
X1.msg0= message0;
X2.msg1= message1;
type_Array Vector[2];
Vector[0]= X1;
Vector[1]= X2;
return 0;
}
|
|
|
|
|
hi
(again what I would like to have is an array of message0, message1...)
please give me a clue if any
I thought I solved it.. unfortunally I cannot refer the buffer I need.
I need message0._c[0] these buffer to refer to.
the only way is with sintax: Vector[0].msg0._c[0]=1; //ok // not usefull
i have to apppend .msg0 which is not usefull
// diff types array.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
typedef struct
{
unsigned char signal7 : 8;
unsigned char signal6 : 8;
unsigned char signal5 : 8;
unsigned char signal4 : 8;
unsigned char signal3 : 8;
unsigned char signal2 : 8;
unsigned char signal1 : 8;
unsigned char signal0 : 8;
} msgType0;
typedef union
{
unsigned char _c[8];
msgType0 msg0_0;
} buf0;
buf0 message0;
typedef struct
{
unsigned char signal7 : 8;
unsigned char signal6 : 8;
unsigned char signal5 : 8;
unsigned char signal4 : 8;
unsigned char signal3 : 8;
unsigned char signal2 : 8;
unsigned char signal1 : 8;
unsigned char signal0 : 8;
} msgType1;
typedef union
{
unsigned char _c[8];
msgType1 msg0_1;
} buf1;
buf1 message1;
/// ................................
/// UP is the Driver .. No changed possible
// X 8 times
int main(int argc, char* argv[])
{
printf("Hello World!\n");
union type_Array
{
buf0 msg0;
buf1 msg1;
} ;
type_Array X1;
type_Array X2;
X1.msg0= message0;
X2.msg1= message1;
type_Array Vector[2];
Vector[0]= X1;
Vector[1]= X2;
// what i would like to refer is this buffer message0._c[0]
message0._c[0]= 1;
Vector[0]._c[0]=1; //imposible to use because of refering msg0
//Vector[0].msg0._c[0]=1; //ok // not usefull
return 0;
}
modified on Thursday, January 21, 2010 11:34 AM
|
|
|
|