This site is no longer active and is available for archival purposes only. Registration and login is disabled.

Help with function win32 to wince functions


Help with function win32 to wince functions

Postby R0B » Dec 6, 2001 @ 8:14pm

Ok, here is the first of many questions that I will be asking on my epic quest to pot a program that will be revealed when it is nearly done (or at least capable of having a screen shot taken of it.  If I port it completely, then at least the 720 owners, if not all ppc owners are in for a real treat.<br><br>Ok, Here are the first two functions I am haveing porblems finding in the hpc2000 sdk<br>1. access(const char *, int);  //Located in IO.h<br>2. _findfirst(const char *, struct _finddata_t *); //Located in IO.h<br><br>The code where these two functions are used will follow, but here is what I already know about them. (1 refers to access, and 2 reffers to _findfirst)<br>1. Checks to see if you have some type of permission to access a file.  In my case, checks for read permision.<br><br>//Code<br>miscvar=access(filename,4); //Checks to see if you can read the file <br><br>2. (Not sure about this one). Searches for all files that have "const char *", and stores results at "struct _finddata_t *" ???<br><br>//Code<br>if((miscvar=_findfirst("*.*",&miscvar2))!=-1) //Looks for all files???<br><br><br>If you could please help me emulate or get a good substitution for these files I would greately appriciate it.  Thanks.
"1011001010 NNNNNNNNNNOOOOOOOOOOOOOOOO!!!!!!" -Bender
User avatar
R0B
got muffins?
 
Posts: 1894
Joined: Jun 22, 2001 @ 12:04pm


Re: Help with function win32 to wince functions

Postby Digby » Dec 6, 2001 @ 11:32pm

Digby
pm Insider
 
Posts: 1011
Joined: Apr 29, 2001 @ 1:53pm


Re: Help with function win32 to wince functions

Postby Dan East » Dec 6, 2001 @ 11:43pm

Heh heh! :) I guess you type faster than me Digby. There, now you have two solutions to a problem using two different mechanisms, from two great coders. ;)<br><br>Dan East
User avatar
Dan East
Site Admin
 
Posts: 5264
Joined: Jan 25, 2001 @ 5:19pm
Location: Virginia, USA


Re: Help with function win32 to wince functions

Postby Dan East » Dec 6, 2001 @ 11:44pm

The Windows API FindFirstFile, FindNextFile and FindClose will provide the solution to implementing both those functions. FindFirstFile and FindNextFile fill a struct (WIN32_FIND_DATA) with information about the found file (attributes, file times, size, etc). Check WIN32_FIND_DATA::dwFileAttributes for the bits FILE_ATTRIBUTE_READONLY to be set set for the access function.  Ahh, heck, I'll just code _access for you:<br>[fixed]<br>int _access(const char *path, int mode) {<br>  //Have to convert to UNICODE<br>  TCHAR fname[MAX_PATH];<br>  MultiByteToWideChar( CP_ACP, 0, path, -1,<br>    fname, sizeof( fname )/sizeof( TCHAR ) );<br>  <br>  WIN32_FIND_DATA ffd;<br>  //Get info on target file<br>  HANDLE h=FindFirstFile( fname, &ffd );<br><br>  if ( h==INVALID_HANDLE_VALUE )<br>    return -1;  //Can't find file<br>  FindClose( h );<br><br>  if (ffd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)<br>    return 0; //Always return success if target is directory and exists<br><br>  switch ( mode ) {<br>    case 00: //Check existance<br>      return 0;<br>    case 06: //Check Read & Write permission<br>    case 02: //Check Write permission<br>      return ffd.dwFileAttributes&FILE_ATTRIBUTE_READONLY?-1:0;<br>    case 04: //Check Read permission<br>      return 0; //Assume always have read permission<br>  } <br>  //Bad mode value supplied, return failure<br>  return -1;<br>}[/fixed]<br><br>That assumes a file can always be read, thus it obviously is not taking into account file locking due to access by an application. I doubt the true implementation of _access does that anyways - it probably goes by file permissions only.<br><br>Dan East
User avatar
Dan East
Site Admin
 
Posts: 5264
Joined: Jan 25, 2001 @ 5:19pm
Location: Virginia, USA


Re: Help with function win32 to wince functions

Postby RICoder » Dec 7, 2001 @ 1:25am

You fuckin' guys!  GEEKS!<br><br>Ok, only because I didn't get here first...<br><br>:-D
<iframe src="http://gamercard.xbox.com/RICoder.card" scrolling="no" frameBorder="0" height="140" width="204">RICoder</iframe>
User avatar
RICoder
FOX News Correspondent
 
Posts: 3948
Joined: Jul 10, 2001 @ 1:48pm
Location: the matrix has me


Re: Help with function win32 to wince functions

Postby Matt Keys » Dec 7, 2001 @ 5:04pm

ok, now use them both and tell us which code is better/faster:)
Matt Keys
Co-Founder
PocketMatrix.com
User avatar
Matt Keys
Site Co-Founder
 
Posts: 3243
Joined: Jan 24, 2001 @ 7:29pm
Location: Michigan, USA


Re: Help with function win32 to wince functions

Postby R0B » Dec 7, 2001 @ 8:17pm

Alright, thanks for your help.  I'll try both of them out in a minute, and see which one works better.  You guys are great, but don't think that this was the only question you'll have to answer because there will be plenty more ;)
"1011001010 NNNNNNNNNNOOOOOOOOOOOOOOOO!!!!!!" -Bender
User avatar
R0B
got muffins?
 
Posts: 1894
Joined: Jun 22, 2001 @ 12:04pm


Re: Help with function win32 to wince functions

Postby R0B » Dec 7, 2001 @ 9:32pm

"1011001010 NNNNNNNNNNOOOOOOOOOOOOOOOO!!!!!!" -Bender
User avatar
R0B
got muffins?
 
Posts: 1894
Joined: Jun 22, 2001 @ 12:04pm


Re: Help with function win32 to wince functions

Postby Dan East » Dec 7, 2001 @ 10:06pm

User avatar
Dan East
Site Admin
 
Posts: 5264
Joined: Jan 25, 2001 @ 5:19pm
Location: Virginia, USA


Re: Help with function win32 to wince functions

Postby Digby » Dec 7, 2001 @ 10:43pm

Digby
pm Insider
 
Posts: 1011
Joined: Apr 29, 2001 @ 1:53pm


Re: Help with function win32 to wince functions

Postby Dan East » Dec 7, 2001 @ 10:55pm

User avatar
Dan East
Site Admin
 
Posts: 5264
Joined: Jan 25, 2001 @ 5:19pm
Location: Virginia, USA


Re: Help with function win32 to wince functions

Postby R0B » Dec 7, 2001 @ 11:15pm

"1011001010 NNNNNNNNNNOOOOOOOOOOOOOOOO!!!!!!" -Bender
User avatar
R0B
got muffins?
 
Posts: 1894
Joined: Jun 22, 2001 @ 12:04pm


Re: Help with function win32 to wince functions

Postby R0B » Dec 7, 2001 @ 11:20pm

"1011001010 NNNNNNNNNNOOOOOOOOOOOOOOOO!!!!!!" -Bender
User avatar
R0B
got muffins?
 
Posts: 1894
Joined: Jun 22, 2001 @ 12:04pm


Re: Help with function win32 to wince functions

Postby Dan East » Dec 7, 2001 @ 11:34pm

User avatar
Dan East
Site Admin
 
Posts: 5264
Joined: Jan 25, 2001 @ 5:19pm
Location: Virginia, USA


Return to Windows Mobile


Sort


Forum Description

A discussion forum for mobile device developers on the Windows Mobile platform. Any platform specific topics are welcome.

Moderators:

Dan East, sponge, Digby, David Horn, Kevin Gelso, RICoder

Forum permissions

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

cron