cmCTestUploadCommand.cxx 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. this->SetError("internal CTest error. Cannot instantiate upload handler");
  20. return 0;
  21. }
  22. static_cast<cmCTestUploadHandler*>(handler)->SetFiles(this->Files);
  23. handler->SetQuiet(this->Quiet);
  24. return handler;
  25. }
  26. bool cmCTestUploadCommand::CheckArgumentKeyword(std::string const& arg)
  27. {
  28. if (arg == "FILES") {
  29. this->ArgumentDoing = ArgumentDoingFiles;
  30. return true;
  31. }
  32. if (arg == "QUIET") {
  33. this->ArgumentDoing = ArgumentDoingNone;
  34. this->Quiet = true;
  35. return true;
  36. }
  37. return false;
  38. }
  39. bool cmCTestUploadCommand::CheckArgumentValue(std::string const& arg)
  40. {
  41. if (this->ArgumentDoing == ArgumentDoingFiles) {
  42. std::string filename(arg);
  43. if (cmSystemTools::FileExists(filename.c_str())) {
  44. this->Files.insert(filename);
  45. return true;
  46. } else {
  47. std::ostringstream e;
  48. e << "File \"" << filename << "\" does not exist. Cannot submit "
  49. << "a non-existent file.";
  50. this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
  51. this->ArgumentDoing = ArgumentDoingError;
  52. return false;
  53. }
  54. }
  55. // Look for other arguments.
  56. return this->Superclass::CheckArgumentValue(arg);
  57. }