示例#1
0
BOOL fileAutoRename(PSTR szName,DWORD dwName)
{
  char   szPath[_MAX_PATH];
  char   szTemp[_MAX_PATH];
  char   szExt[_MAX_PATH];
  PSTR   pName,pExt,pOrd;
  DWORD  dwOrd;
  HANDLE hFile;
  
  //not exist ?
  if (INVALID_HANDLE_VALUE != (hFile=CreateFile(szName,GENERIC_WRITE,0,NULL,CREATE_NEW,FILE_ATTRIBUTE_NORMAL,NULL))){
    CloseHandle(hFile);
	return TRUE;
  }
  strcpyN(szPath,sizeof(szPath),szName);
  pName = PathFindFileName(szPath);
  pExt  = PathFindExtension(pName);
  strcpyN(szExt,sizeof(szExt),pExt);
  pOrd = pExt - 1;
  for(;;pOrd++){
    if (*pOrd < '0' || *pOrd > '9') break;
  }
  pOrd++;
  dwOrd = atoi(pOrd);
  pOrd[0] = 0;
  for(;dwOrd<INT_MAX-1;dwOrd++){
    strcpyV(szTemp,sizeof(szTemp),"%s%d%s",szPath,dwOrd,szExt);
	if (INVALID_HANDLE_VALUE != (hFile=CreateFile(szTemp,GENERIC_WRITE,0,NULL,CREATE_NEW,FILE_ATTRIBUTE_NORMAL,NULL))){
      CloseHandle(hFile);
	  strcpyN(szName,dwName,szTemp);
      return TRUE;
    }
  }
  return FALSE;
}
示例#2
0
Tex * newLetter(char * data, int x, int y, int size, int bpp, int w)
{
	/* Create a single letter						(deylen - 14/5/2009)*/

	int a;
	char * letterDat = newStr(size * (size * bpp));
	char * p, * p2 = letterDat;
	Tex * letter;

	p = data + (x * (size * bpp)) + (y * (size * (w * bpp)));
	/* Setting the start point of our texture 				(deylen - 14/05/2009)*/

	/* - - - - - - - - - - *
	 * - - - - _ _ - - - - *
	 * - - - |     | - - - *
	 * - @ - |  A  | - B - *
	 * - - - | _ _ | - - - *
	 * - - - - - - - - - - *
	 * - - - - - - - - - - *
	 *
	 *   A is the area of the whole texture that we will extract for our letter 				(deylen - 14/05/2009)*/

	for (a=0; a < size; a++){
		p2 = strcpyN(p2, p, size * bpp);
		p += w * bpp;
	}/* copying the data into letterDat by way of pointer p2						(deylen - 14/05/2009)*/
	/* add <w * bpp> to move to the next row of the texture						(deylen - 14/05/2009)*/

	letter = newTexChar(letterDat, size, size, bpp);
	free(letterDat);

	return letter;
}