PocketMatrix forums

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

IS THERE A PPC EQUIVALENT

Code:

#include <sys/types.h>
#include <sys/stat.h>


The above code is used on a desktop application for getting file info, ithere equivalents for Pocket PC and if so, does anyone know what these are .??
"Open" the file with FindFirstFile, which will fill out at WIN32_FIND_DATA struct for you.

Dan East
Code:

#include <sys/types.h>
#include <sys/stat.h>

#if defined(_MSC_VER)
#define stat _stat
#endif

void FILEOBJECT:: SetPath ( char* ptr)
{
FullName = ptr;
STRINGC lstr = ptr;
lstr.Lower();
lstr.ConvertBackslash();
FileName = lstr;
FilePath = lstr;
lstr.ExtractExtension();
FilePath.ExtractPath();
FileName.ExtractFileName();

if ( strstr(lstr, "lle") != 0 ) FileType = LLE;
if ( strstr(lstr, "bmp") != 0 ) FileType = BMP;
if ( strstr(lstr, "tga") != 0 ) FileType = TGA;
if ( strstr(lstr, "sav") != 0 ) FileType = SAV;
if ( strstr(lstr, "dat") != 0 ) FileType = DAT;
if ( strstr(lstr, "vat") != 0 ) FileType = VAT;
if ( strstr(lstr, "txt") != 0 ) FileType = TXT;
}

int FILEOBJECT:: DoesFileExist()// verifies the existance of a file, use SetPath first
{
if (FullName.GetString() == NULL) return false;

struct stat buf;

if ( stat(FullName, &buf) == -1) return false;
return true;
}


This what i have and im not sure how i could do this in WinCE
To see if the file exists you can just try to fopen it or use FindFirstFile. That's trivial.

Unfortunately Windows CE does not include the win32 routine (_splitpath) to split a filename into the components (path, filename and extension), which is pretty lame considering it takes less than a dozen lines of code to extract the path from a filename. So you would have to write one yourself. It's just basic string parsing.

If all you need to do is test extensions then that can easily be done without extracting the actual extension:
Code:

int len=strlen(sFilename);
if (len>=4) {
char *pExtension=&sFilename;[len-4];
if (!strcmp(".yep", pExtension))
FileType=YEP;
else
if (!strcmp(".bad", pExtension))
FileType=BAD;
//etc
}


That would require minor modification to support extensions that aren't 3 chars in length.

Dan East
Thanks for all your help , i can see some light