|
I have different descriptions to the same file, such as "c:\tmp\test.dat", "c:\tmp\..\tmp\test.dat" etc - the variations are endless.
What is the easiest way to normalize the paths so that I can compare two or more and determine they refer to the same file?
Note the file may not yet exist.
I thought the Shell API had something but was unsuccessful with my search through MSDN. Anybody to point me to some standaed Win32 API to solve that problem?
TIA,
Bernd
|
|
|
|
|
Does GetFullPathName() do the trick?
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
Unfortunately not. GetFullPathName() does what the name suggests, but does not normalize.
Thanks for making an effort anyhow
Bernd
|
|
|
|
|
How about _fullpath() ?
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
How can I clear a file with fstream?
I've opened my file with append flag, so I can't do:
my_fstream.write("", 0);
Bye
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
Rickard Andersson wrote:
How can I clear a file with fstream?
I've opened my file with append flag, so I can't do:
Why not just close the file and re-open it with ios::trunc? .... I suppose there is probably a faster way.
-Nick Parker
The true measure of a man is how he treats someone who can do him absolutely no good. - Samuel Johnson
|
|
|
|
|
Nick Parker wrote:
Why not just close the file and re-open it with ios::trunc? .... I suppose there is probably a faster way.
... and better.
I've derived a class from fstream and when my app starts I open a log file and keep that log file opened while my app i running. I don't want to close it during runtime...
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
Have you looked at fstream::fd
A file descriptor as returned by a call to the run-time function _open or _sopen. filedesc is a typedef equivalent to int.
Then use it in _chsize( int handle, long size );
I have never tried this, so I don't know if it will work, it is supposed to
If I have seen further it is by standing on the shoulders of Giants. - Isaac Newton 1676
|
|
|
|
|
A C function?
Okay, it's seems that there is no way to do it in C++....
Thank you!
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
I may be wrong of course. But that is the best I could find, after all fstream does use standard C calls eventuallyt.
If I have seen further it is by standing on the shoulders of Giants. - Isaac Newton 1676
|
|
|
|
|
dear all,
i've an sdk application with a window.
on the WM_QUERYENDSESSION message, a message box pops up.
i 've 2 problems
1) if i make my window hidden (SW_HIDE), all the message boxes are also hidden( fired on WM_QUERYENDSESSION)
so how do i ensure that the message box is visible even if window is hidden.
2) how do i kill the message box say after 5 seconds
thanx and regards
rishabhs
|
|
|
|
|
Try IsWindowVisible(). As for a clock, one solution is a SetTimer. Another solution is a thread, event kernel object, and WaitForSingleObject). Finally, you can implement a timer queue timer.
Kuphryn
|
|
|
|
|
1) Showing message box: Try passing NULL as the handle to the parent window, since if the parent is hidden so are its children. (Refer do help for more info.)
2) Automatic closing of message box: Try
'A thread-safe timed message box' at
http://www.codeproject.com/dialog/msgboxdemo.asp
or search codeproject for other articles.
Trust in the code Luke. Yea right!
|
|
|
|
|
thanx a lot guys
i've passed NULL in the first parameter of MessageBox(..) but still it is invisible
Regards
rishabhs
|
|
|
|
|
// The following is a test that shows how to make the
// message box visable, even if parent is hidden. Both
// the commented and uncommented lines below worked.
// Note: MB_TOPMOST flag.
void CMainFrame::OnTimer(UINT nIDEvent)
{
KillTimer(123);
ShowWindow(SW_HIDE);
//::MessageBox(NULL,_T("Test hide"),_T("Test"),MB_OK|MB_TOPMOST);
MessageBox(_T("Test hide"),_T("Test"),MB_OK|MB_TOPMOST);
ShowWindow(SW_SHOW);
CFrameWnd::OnTimer(nIDEvent);
}
void CMainFrame::OnSize(UINT nType, int cx, int cy)
{
CFrameWnd::OnSize(nType, cx, cy);
if( nType == SIZE_MINIMIZED )
SetTimer(123,1000,NULL);
}
Trust in the code Luke. Yea right!
|
|
|
|
|
Can any one help me in multithreading
I am using the AfxBeginThread() method to initialize thread but I am using it for a single thread at the mement But I want to initiate more threads for my assignment
How can I do it?
Please refer any helping material website or helping sample which can guide me to tackle with more than one threads.
Reply me soon
|
|
|
|
|
|
Hi all
I have the following scenario
typedef struct _STRRET{
UINT uType;
union
{
LPWSTR pol;
UINT uof;
char cStr[MAX_PATH];
}DUMMYUNIONNAME;
}STRRET , *LPSTRRET;
The problem is when i make a variable of type STRRET i couldn't acces the union variables. The following line include the code i wrote
STRRET dispName;
LPWSTR temp;
temp = dispName.DUMMYUNIONNAME.pol;
The compiler gives me compiling error:
C2059 syntax error: '.'
see declaration of _STRRET (which i know very good)
Note: the above struct is a MFC defined type and don't know were is the problem may i have accessing the union in a wrong way or something.
Sorry for my very stupid question and thanks for ur time in advance.
Together we are stronger.
I am so
M.A.S.A
|
|
|
|
|
Using another union name than DUMMYUNIONNAME solves the problem.
|
|
|
|
|
I am sorry _Theo_ i don't understand u. The union name is defined in the MFC and i have no authority to midify it. So I must use the "DUMMYUNIONNAME " union name.
Plllllllllllssssssssssss If u know any way of solving this problem i will be very greatful if u send it to me.
Thank u Any way for ur quick reply and waiting for ur reply. I really want a solution for this problem.
M.A.S.A
|
|
|
|
|
Sorry I didn't realise it's a predefined structure. Leaving DUMMYUNIONNAME seems to work, so instead of using it call the union attributes right away like:
<br />
temp = dispName.pol;<br />
|
|
|
|
|
_Theo_ thank u veeeeeeeeeeeeeeeeeeeeryyyyyyyyyyyy muchhhhhhhhhhhhhhhhhhhhhhh
I don't know how to thank u for ur advice.
U will not belive me that i have tried it before and it didn't work but after reading ur message i tried it again but this time it works. This job will make me made especially this stupid mistakes.
Thank u again.
|
|
|
|
|
Just to clarify why this works:
Microsoft uses a #define for DUMMYUNIONNAME so that the same include file can be used with compilers that don't support unnamed unions. When you compile using Visual C++, the DUMMYUNIONNAME is #defined to a blank string, so the union doesn't have a name (and its members can be accessed directly). When you compile on a compiler which doesn't support unnamed unions, it is #defined to u (and you would need to include the .u before the member name).
|
|
|
|
|
Hi...I'm working with trigonometric functions in visual C++ V6.0.
I have this program that converts degrees to radians, applies some direct trigonometric functions, and then some inverse functions.
The inverse function I'm using is the ATAN2(y,x). I have checked the function and it uses the definition of pi=3.141592653589793116E00.
The examples given in the MSN documentation uses pi=3.1415926535 giving the correct results.
Then, I was using the last definition of pi to convert degrees to radians and viceversa, but using also the atan2(y,x) function, and I'm getting that:
cos(90. degrees)=-3.4914833611094e-15
Then, because the definition of pi is different in the conversion and the function, I have decided to make it uniform, as I cannot change the definition of pi in the atan2() function, I decided to change the definition of pi used for the conversions, however, I ave got the following:
cos(90. degrees)=-6.1230317691119e-017
Which is less than the previous result, but still is not correct.
Is there anyway to avoid this situation?
Thanks,
Eric Manuel Rosales Pena Alfaro
PhD student
Unversity of Essex
Wivenhoe Park
Colchester, CO4 3SQ
Essex, Uk
email: emrosa@essex.ac.uk
tel: +44-01206-87311
|
|
|
|
|
emrosa wrote:
cos(90. degrees)=-3.4914833611094e-15
cos(90. degrees)=-6.1230317691119e-017
You should never expect to get exactly 0. Floating-point numbers and operations are not exact.
It seems to me that
-0.0000000000000034914833611094
and
-0.000000000000000061230317691119
are pretty close to 0.
|
|
|
|