cmCTestUploadCommand.cxx 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #include "cmCTestUploadCommand.h"
  11. #include "cmCTest.h"
  12. #include "cmCTestGenericHandler.h"
  13. #include "cmCTestUploadHandler.h"
  14. cmCTestGenericHandler* cmCTestUploadCommand::InitializeHandler()
  15. {
  16. cmCTestGenericHandler* handler
  17. = this->CTest->GetInitializedHandler("upload");
  18. if ( !handler )
  19. {
  20. this->SetError("internal CTest error. Cannot instantiate upload handler");
  21. return 0;
  22. }
  23. static_cast<cmCTestUploadHandler*>(handler)->SetFiles(this->Files);
  24. handler->SetQuiet(this->Quiet);
  25. return handler;
  26. }
  27. //----------------------------------------------------------------------------
  28. bool cmCTestUploadCommand::CheckArgumentKeyword(std::string const& arg)
  29. {
  30. if(arg == "FILES")
  31. {
  32. this->ArgumentDoing = ArgumentDoingFiles;
  33. return true;
  34. }
  35. if(arg == "QUIET")
  36. {
  37. this->ArgumentDoing = ArgumentDoingNone;
  38. this->Quiet = true;
  39. return true;
  40. }
  41. return false;
  42. }
  43. //----------------------------------------------------------------------------
  44. bool cmCTestUploadCommand::CheckArgumentValue(std::string const& arg)
  45. {
  46. if(this->ArgumentDoing == ArgumentDoingFiles)
  47. {
  48. std::string filename(arg);
  49. if(cmSystemTools::FileExists(filename.c_str()))
  50. {
  51. this->Files.insert(filename);
  52. return true;
  53. }
  54. else
  55. {
  56. std::ostringstream e;
  57. e << "File \"" << filename << "\" does not exist. Cannot submit "
  58. << "a non-existent file.";
  59. this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
  60. this->ArgumentDoing = ArgumentDoingError;
  61. return false;
  62. }
  63. }
  64. // Look for other arguments.
  65. return this->Superclass::CheckArgumentValue(arg);
  66. }