Changeset 598 for CMT


Ignore:
Timestamp:
Dec 11, 2011, 3:30:43 PM (12 years ago)
Author:
rybkin
Message:

See C.L. 475

Location:
CMT/HEAD
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • CMT/HEAD/ChangeLog

    r597 r598  
     12011-12-11    <rybkin@lal.in2p3.fr> 475
     2
     3        * source/cmt_error.h: In class CmtError, introduce system_error code
     4        * source/cmt_error.cxx: In class TheError, in constructor add introduced
     5        system_error code string name
     6        * source/cmt_parser.cxx: In class Cmt, in function do_create, check return
     7        value of all invoked functions, set error on failure making use of
     8        system_error code, and return, so that exit value of "cmt create" command
     9        be set according to command success/failure
     10
    1112011-12-11    <rybkin@lal.in2p3.fr> 474
    212
  • CMT/HEAD/source/cmt_error.cxx

    r530 r598  
    3030    error_names.add() = "version conflict";
    3131    error_names.add() = "file access error";
     32    error_names.add() = "system error";
    3233    error_names.add() = "configuration error";
    3334    error_names.add() = "execution error";
  • CMT/HEAD/source/cmt_error.h

    r530 r598  
    3131    version_conflict,
    3232    file_access_error,
     33    system_error,
    3334    configuration_error,
    3435    execution_error,
  • CMT/HEAD/source/cmt_parser.cxx

    r595 r598  
    33863386
    33873387  the_path = CmtSystem::pwd ();
     3388  if (0 == the_path.size ())
     3389    {
     3390      CmtError::set (CmtError::system_error, "pwd empty");
     3391      return;
     3392    }
    33883393
    33893394  if (offset != "")
     
    34203425      if (!CmtSystem::mkdir (the_path))
    34213426        {
    3422           CmtMessage::error ("Cannot create the path directory");
    3423           //          cout << "Cannot create the path directory" << endl;
     3427          CmtError::set (CmtError::system_error,
     3428                         "Cannot create path directory " + the_path);
     3429          //CmtMessage::error ("Cannot create path directory " + the_path);
    34243430          return;
    34253431        }
     
    34273433        {
    34283434          if (CmtMessage::active (Info))
    3429             cout << "Installing the path directory" << endl;
    3430         }
    3431     }
    3432 
    3433   CmtSystem::cd (the_path);
     3435            cout << "Installing path directory " << the_path << endl;
     3436        }
     3437    }
     3438
     3439  if (!CmtSystem::cd (the_path))
     3440    {
     3441      CmtError::set (CmtError::system_error,
     3442                     "Cannot cd to path directory " + the_path);
     3443      return;
     3444    }
    34343445
    34353446  if (!CmtSystem::test_directory (package))
     
    34373448      if (!CmtSystem::mkdir (package))
    34383449        {
    3439           CmtMessage::error ("Cannot create the package directory");
    3440           //          cout << "Cannot create the package directory" << endl;
     3450          CmtError::set (CmtError::system_error,
     3451                         "Cannot create package directory " + package);
     3452          //          CmtMessage::error ("Cannot create the package directory");
    34413453          return;
    34423454        }
     
    34443456        {
    34453457          if (CmtMessage::active (Info))
    3446             cout << "Installing the package directory" << endl;
     3458            cout << "Installing package directory" << endl;
    34473459        }
    34483460    }
     
    34533465    }
    34543466
    3455   CmtSystem::cd (package);
     3467  if (!CmtSystem::cd (package))
     3468    {
     3469      CmtError::set (CmtError::system_error,
     3470                     "Cannot cd to package directory " + package);
     3471      return;
     3472    }
     3473  //  CmtSystem::cd (package);
    34563474
    34573475  Use& current_use = Use::current ();
     
    34853503          if (!CmtSystem::mkdir (version))
    34863504            {
    3487               CmtMessage::error ("Cannot create the version directory");
    3488               //              cout << "Cannot create the version directory" << endl;
     3505              //CmtMessage::error ("Cannot create the version directory");
     3506              CmtError::set (CmtError::system_error,
     3507                             "Cannot create version directory " + version);
    34893508              return;
    34903509            }
     
    34923511            {
    34933512              if (CmtMessage::active (Info))
    3494                 cout << "Installing the version directory" << endl;
     3513                cout << "Installing version directory" << endl;
    34953514            }
    34963515        }
     
    35013520        }
    35023521
    3503       CmtSystem::cd (version);
     3522      if (!CmtSystem::cd (version))
     3523        {
     3524          CmtError::set (CmtError::system_error,
     3525                         "Cannot cd to version directory " + version);
     3526          return;
     3527        }
     3528      //      CmtSystem::cd (version);
    35043529    }
    35053530  else
     
    35153540          if (!CmtSystem::mkdir ("cmt"))
    35163541            {
    3517               CmtMessage::error ("Cannot create the cmt directory");
    3518 //              cout << "Cannot create the cmt directory" << endl;
     3542              CmtError::set (CmtError::system_error,
     3543                             "Cannot create cmt directory");
     3544              //CmtMessage::error ("Cannot create the cmt directory");
    35193545              return;
    35203546            }
     
    35333559
    35343560              if (CmtMessage::active (Info))
    3535                 cout << "Installing the cmt directory" << endl;
     3561                cout << "Installing cmt directory" << endl;
    35363562            }
    35373563        }
     
    35763602      if (!CmtSystem::mkdir ("src"))
    35773603        {
    3578           CmtMessage::error ("Cannot create the src directory");
    3579           //          cout << "Cannot create the src directory" << endl;
     3604          CmtError::set (CmtError::system_error,
     3605                         "Cannot create src directory");
     3606          //CmtMessage::error ("Cannot create the src directory");
    35803607          return;
    35813608        }
     
    35833610        {
    35843611          if (CmtMessage::active (Info))
    3585             cout << "Installing the src directory" << endl;
     3612            cout << "Installing src directory" << endl;
    35863613        }
    35873614    }
     
    35963623    case cmt_style:
    35973624      //    case no_version_style:
    3598       CmtSystem::cd ("cmt");
     3625      if (!CmtSystem::cd ("cmt"))
     3626        {
     3627          CmtError::set (CmtError::system_error,
     3628                         "Cannot cd to package cmt directory ");
     3629          return;
     3630        }
     3631      //CmtSystem::cd ("cmt");
    35993632      break;
    36003633    case mgr_style:
    3601       CmtSystem::cd ("mgr");
     3634      if (!CmtSystem::cd ("mgr"))
     3635        {
     3636          CmtError::set (CmtError::system_error,
     3637                         "Cannot cd to package mgr directory ");
     3638          return;
     3639        }
     3640      //CmtSystem::cd ("mgr");
    36023641      break;
    36033642    }
     
    36093648      // create an empty requirement file.
    36103649      ofstream f ("requirements");
    3611       if (f)
    3612         {
     3650      if (!f)
     3651        {
     3652          CmtError::set (CmtError::file_access_error, "requirements");
     3653          return;
     3654        }
     3655      f.exceptions (ios::failbit | ios::badbit);
     3656      try
     3657        {
    36133658          f << "package " << package << endl;
    36143659          f << endl;
    3615           f.close ();
    3616         }
     3660          f.close (); // ios_base::failbit
     3661        }
     3662      catch (const ios::failure& e)
     3663        {
     3664          CmtSystem::close_ostream (NULL, "requirements: " + cmt_string (e.what ()));
     3665        }
    36173666    }
    36183667
     
    36213670      //      ofstream f ("version.cmt");
    36223671      ofstream f (Package::get_version_file_name ());
    3623       if (f)
    3624         {
     3672      if (!f)
     3673        {
     3674          CmtError::set (CmtError::file_access_error,
     3675                         Package::get_version_file_name ());
     3676          return;
     3677        }
     3678      f.exceptions (ios::failbit | ios::badbit);
     3679      try
     3680        {
    36253681          f << version << endl;
    3626           f.close ();
    3627         }
     3682          f.close (); // ios_base::failbit
     3683        }
     3684      catch (const ios::failure& e)
     3685        {
     3686          CmtSystem::close_ostream (NULL, Package::get_version_file_name () +
     3687                                    + ": " + cmt_string (e.what ()));
     3688        }
    36283689    }
    36293690
     
    36323693  Me.m_current_path    = the_path;
    36333694  Me.m_current_dir     = CmtSystem::pwd ();
     3695  if (0 == Me.m_current_dir.size ())
     3696    {
     3697      CmtError::set (CmtError::system_error, "pwd empty");
     3698      return;
     3699    }
    36343700
    36353701  do_config (ap);
Note: See TracChangeset for help on using the changeset viewer.