Exemple #1
0
// Store the name of source file into the set src
int get_source(const TCHAR *path, ExerSet &src)
{
	WIN32_FIND_DATA ffd;
	TCHAR szDir[MAX_PATH];
	size_t length_of_arg;
	HANDLE hFind = INVALID_HANDLE_VALUE;
	DWORD dwError=0;
	StringCchLength(path, MAX_PATH, &length_of_arg);
	// Check that the input path plus 3 is not longer than MAX_PATH.
	// Three characters are for the "\*" plus NULL appended below.
	if (length_of_arg > (MAX_PATH - 3))
	{
		_tprintf(TEXT("\nDirectory path is too long.\n"));
		return (-1);
	}
	// Prepare string for use with FindFile functions.  First, copy the
	// string to a buffer, then append '\*' to the directory name.
	StringCchCopy(szDir, MAX_PATH, path);
	StringCchCat(szDir, MAX_PATH, TEXT("\\*"));
	// Find the first file in the directory.
	hFind = FindFirstFile(szDir, &ffd);
	if (INVALID_HANDLE_VALUE == hFind) 
	{
		DisplayErrorBox(TEXT("FindFirstFile"));
		return dwError;
	} 
	// get all of the CPP source file names and analysis them
	do {
		if (!(ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
			if (iscpp(ffd.cFileName)) {
				auto exercise_no = analyse_filename(ffd.cFileName);
				for (auto n : exercise_no) {
					src[n].push_back(ffd.cFileName);
				}
			}
		}
	} while (FindNextFile(hFind, &ffd) != 0);
	dwError = GetLastError();
	if (dwError != ERROR_NO_MORE_FILES)
	{
		DisplayErrorBox(TEXT("FindFirstFile"));
	} else {
		dwError = 0;
	}
	
	FindClose(hFind);
	return dwError;
}
Exemple #2
0
//----------------------------------------- Ctor ---------------------------------------------
//--------------------------------------------------------------------------------------------
void Bullet::Initialise(float xPos, float yPos, float xVel, float yVel, double rotation)
{

	GameObject::Initialise(xPos, yPos, 0.0) ;

	// load textures for the Bullet
	GameObject::mObjectTex		= hge->Texture_Load("Resources/Textures/Bullet.png") ;
	GameObject::mpObjectSpr	= new hgeSprite(GameObject::mObjectTex, 0.0f, 0.0f, 16.0f, 16.0f) ;
	GameObject::mpObjectSpr->SetHotSpot(10.0f, 10.0f) ;

	if(!GameObject::mObjectTex)
	{
		// If one of the data files is not found
		DisplayErrorBox("Bullet initialisation error - Texture.") ;
	}


    // Bullet movement speed factor
	GameObject::mVelocity.x	*= 5.0f ;
    GameObject::mVelocity.y	*= 5.0f ;
 
    // No rotation or rotational speed
    mAngle				= 0.0f ;
    mMaxRotationalSpeed	= 0.0f ;


	GameObject::mDragFactor		= 0.0f ;
	GameObject::mScaleFactor	= 0.4f ;
	GameObject::mVelocityLimit	= 1000.0f ;
	GameObject::mIsActive		= false ;

	mBulletTime = MAX_BULLET_TIME ;

}
int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
                     _In_opt_ HINSTANCE hPrevInstance,
                     _In_ LPTSTR    lpCmdLine,
                     _In_ int       nCmdShow)
{
   LPWIN32_FIND_DATAW ffd;
   LARGE_INTEGER filesize;
   WCHAR szDir[MAX_PATH];
   size_t length_of_arg;
   HANDLE hFind = INVALID_HANDLE_VALUE;
   DWORD dwError=0;
   LPWSTR *szArgList;
   int argCount;

   std::ofstream logFile;
   logFile.open ("FileListing.log");

   
   // If the directory is not specified as a command-line argument,
   // print usage.

  szArgList = CommandLineToArgvW((LPCWSTR)GetCommandLine(), &argCount);

  if(argCount !=2)
	  logFile << "\nUsage: %s <directory name>\n" << szArgList[0];

   /*if(argc != 2)
   {
      _tprintf(TEXT("\nUsage: %s <directory name>\n"), argv[0]);
      return (-1);
   }*/

   // Check that the input path plus 3 is not longer than MAX_PATH.
   // Three characters are for the "\*" plus NULL appended below.

   StringCchLengthW(szArgList[1], MAX_PATH,  (size_t *)&argCount);

   if ( argCount > (MAX_PATH - 3))
   {
      logFile << "\nDirectory path is too long.\n";
      return (-1);
   }

  logFile <<"\nTarget directory is "<<szArgList[1] <<":\n\n";

   // Prepare string for use with FindFile functions. First, copy the
   // string to a buffer, then append '\*' to the directory name.

   StringCchCopyW(szDir, MAX_PATH, szArgList[1]);
   StringCchCatW(szDir, MAX_PATH, L"\\*");

   // Find the first file in the directory.

   hFind = FindFirstFileW(szDir, &ffd);

   if (INVALID_HANDLE_VALUE == hFind) 
   {
      DisplayErrorBox(TEXT("FindFirstFile"));
      return dwError;
   } 
   
   // List all the files in the directory with some info about them.

   do
   {
      if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
      {
         _tprintf(TEXT("  %s   <DIR>\n"), ffd.cFileName);
      }
      else
      {
         filesize.LowPart = ffd.nFileSizeLow;
         filesize.HighPart = ffd.nFileSizeHigh;
         _tprintf(TEXT("  %s   %ld bytes\n"), ffd.cFileName, filesize.QuadPart);
      }
   }
   while (FindNextFile(hFind, &ffd) != 0);
 
   dwError = GetLastError();
   if (dwError != ERROR_NO_MORE_FILES) 
   {
      DisplayErrorBox(TEXT("FindFirstFile"));
   }

   FindClose(hFind);
   return dwError;

	return 0;
}