cmCTestUploadCommand.cxx 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. return handler;
  25. }
  26. //----------------------------------------------------------------------------
  27. bool cmCTestUploadCommand::CheckArgumentKeyword(std::string const& arg)
  28. {
  29. if(arg == "FILES")
  30. {
  31. this->ArgumentDoing = ArgumentDoingFiles;
  32. return true;
  33. }
  34. return false;
  35. }
  36. //----------------------------------------------------------------------------
  37. bool cmCTestUploadCommand::CheckArgumentValue(std::string const& arg)
  38. {
  39. if(this->ArgumentDoing == ArgumentDoingFiles)
  40. {
  41. cmStdString filename(arg);
  42. if(cmSystemTools::FileExists(filename.c_str()))
  43. {
  44. this->Files.insert(filename);
  45. return true;
  46. }
  47. else
  48. {
  49. cmOStringStream e;
  50. e << "File \"" << filename << "\" does not exist. Cannot submit "
  51. << "a non-existent file.";
  52. this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
  53. this->ArgumentDoing = ArgumentDoingError;
  54. return false;
  55. }
  56. }
  57. // Look for other arguments.
  58. return this->Superclass::CheckArgumentValue(arg);
  59. }