PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

File Management Functions

First of all, I'm having trouble with _trename (the generic text version of rename). Once again, it works on PC but doesn't build in eVC3. Is it supported on WinCE?

Where can I find a big list of just what eVC3 doesn't support?

Second, what is the proper way to copy a file on the Pocket PC? I know about CopyFile but it doesn't take wide strings as parameters. Which function should I be using?

Any other good tips for file management?
mlepage wrote:First of all, I'm having trouble with _trename (the generic text version of rename). Once again, it works on PC but doesn't build in eVC3. Is it supported on WinCE?

Where can I find a big list of just what eVC3 doesn't support?

Second, what is the proper way to copy a file on the Pocket PC? I know about CopyFile but it doesn't take wide strings as parameters. Which function should I be using?

Any other good tips for file management?

MoveFile or CopyFile don't work for you? My headers say

Code:

WINBASEAPI
BOOL
WINAPI
MoveFileA(
LPCSTR lpExistingFileName,
LPCSTR lpNewFileName
);
WINBASEAPI
BOOL
WINAPI
MoveFileW(
LPCWSTR lpExistingFileName,
LPCWSTR lpNewFileName
);
#ifdef UNICODE
#define MoveFile MoveFileW
#else
#define MoveFile MoveFileA
#endif // !UNICODE

So maybe the UNICODE flag isn't set?

- HM
OK I tried them and they work. I failed to notice the 'T' in LPCTSTR.
Isn't MoveFileEx available on Pocket PC (eVC3)?

I want to overwrite existing files. Is there another recommended way to do it?
In DEXplor I first try to MoveFile it. If MoveFile fails and GetLastError returns ERROR_ALREADY_EXISTS then you know the target already exists. So in that case I CopyFile with bFailIfExists = FALSE, then delete the original source file if CopyFile succeeds. Now if the DeleteFile on the source fails you could delete the copy you just made, but to be safe in DEXplor I do not. So if you try to Move a file that is in use, you end up just making a copy of it.

That is the most fool-proof, fail-safe method I came up with to handle that situation.

Dan East
OK I'll try something similar.

So long as it overwrites the destination file I'm happy, I only care about deleting the source file in one case. (Basically, I have a chain of files I am shifting.)

I also read something about a delete-on-close flag to CreateFile which can be used to delete files in some cases, you might be able to use that in DEXplor.