Пример #1
0
int IsFileSystemDumb(char *dir)
{                         
  char drive[5], path[256], name[256];
  
  _splitpath(dir, drive, path, NULL, NULL);
  _makepath(name, drive, path, ".DUMB.TEST.NAME", NULL);
  
  return !IsFileNameValid(name);
}
Пример #2
0
static KWBoolean advancedFS(const char *input)
{
   static char UUFAR cache[256] = "";  /* Initialize cache to zeroes  */

   char fdrive[_MAX_DRIVE],
        fpath[_MAX_DIR],
        fname[_MAX_FNAME],
        fdummy[_MAX_PATH];

  _splitpath((char *) input, fdrive, fpath, fdummy, fdummy);

/*--------------------------------------------------------------------*/
/*       Determine if our cache holds the answer for the drive        */
/*       if the path begins with an alphabetic character              */
/*--------------------------------------------------------------------*/

   if (isalpha( *fdrive ))
   switch(cache[ (unsigned char) *fdrive ])
   {
      case CACHE_LONG_NAME_SUPPORT:
      case CACHE_SHORT_NAME_ONLY:
         break;                        /* Cached answer, report it   */

      default:                         /* No cache, determine answer */
         strcpy(fname, fdrive);
         strcat(fname, fpath);
         strcat(fname, ".test.only-do.not.ask.questions.about.failures.to.open.this.file");

         cache[ (unsigned char) *fdrive ] =
                     (char) (IsFileNameValid(fname) ? CACHE_LONG_NAME_SUPPORT : CACHE_SHORT_NAME_ONLY);

         printmsg(4, "advancedFS: %s resides on file system supporting %s",
                     input,
                     (char *) (cache[ (unsigned char) *fdrive ] == CACHE_SHORT_NAME_ONLY ?
                               "only 8.3 names" :
                               "long file names"));
         break;
   }

/*--------------------------------------------------------------------*/
/*          Report our now cached results back to the caller          */
/*--------------------------------------------------------------------*/

   if (cache[ (unsigned char) *fdrive ] == CACHE_LONG_NAME_SUPPORT)
      return KWTrue;
   else
      return KWFalse;

} /* advancedFS */
Пример #3
0
//return 0: no error
//return 1: lpPath is invalid
//return 2: lpPath can not be created(bValidate==FALSE)
int CPathDialog::Touch(LPCTSTR lpPath, BOOL bValidate)
{
	if(lpPath==NULL)
	{
		return 1;
	}

	TCHAR szPath[MAX_PATH];
	_tcscpy_s(szPath, lpPath);
	int nLen = _tcslen(szPath);

	//path must be "x:\..."
	if( ( nLen<3 ) || 
		( ( szPath[0]<_T('A') || _T('Z')<szPath[0] ) && 
		  ( szPath[0]<_T('a') || _T('z')<szPath[0] ) ||
		( szPath[1]!=_T(':') )|| 
		( szPath[2]!=_T('\\') )
		)
	  )
	{
		return 1;
	}

	int i;
	if(nLen==3)
	{
		if(!bValidate)
		{
			if(_access(szPath, 0)!=0)
			{
				return 2;
			}
		}
		return 0;
	}

	i = 3;
	BOOL bLastOne=TRUE;
	LPTSTR lpCurrentName;
	while(szPath[i]!=0)
	{
		lpCurrentName = &szPath[i];
		while( (szPath[i]!=0) && (szPath[i]!=_T('\\')) )
		{
			i++;
		}

		bLastOne =(szPath[i]==0);
		szPath[i] = 0;

		if( !IsFileNameValid(lpCurrentName) )
		{
			return 1;
		}

		if(!bValidate)
		{
			CreateDirectory(szPath, NULL);
			if(_taccess(szPath, 0)!=0)
			{
				return 2;
			}
		}

		if(bLastOne)
		{
			break; //it's done
		}
		else
		{
			szPath[i] = _T('\\');
		}

		i++;
	}

	return (bLastOne?0:1);
}