#include <cmt_system.h>
List of all members.
Public Types |
|
| typedef cmt_vector< cmt_string >? | cmt_string_vector |
Static Public Methods |
|
| cmt_string? | pwd () |
| bool? | cd (const cmt_string &dir) |
| void? | basename (const cmt_string &file_name, cmt_string &result) |
| void? | basename (const cmt_string &file_name, const cmt_string &suffix, cmt_string &result) |
| void? | dirname (const cmt_string &file_name, cmt_string &result) |
| void? | name (const cmt_string &file, cmt_string &result) |
| void? | get_suffix (const cmt_string &file, cmt_string &result) |
| void? | get_dot_suffix (const cmt_string &file, cmt_string &result) |
| bool? | has_prefix (const cmt_string &name) |
| bool? | absolute_path (const cmt_string &name) |
| bool? | has_device (const cmt_string &name) |
| cmt_string? | current_branch () |
| bool? | test_directory (const cmt_string &name) |
| ? |
Implementation of the "test -d" equivalent. |
| bool? | test_file (const cmt_string &name) |
| ? |
Implementation of the "test -f" equivalent. |
| bool? | compare_files (const cmt_string &name1, const cmt_string &name2) |
| ? |
Check if the file "name1" is identical to "name2". |
| bool? | compare_and_update_files (const cmt_string &name1, const cmt_string &name2) |
| ? |
Check if the file "name1" is identical to "name2" if they are identical, "name1" will be simply deleted otherwise "name1" will be copied to "name2" and deleted afterwards. |
| int? | file_size (const cmt_string &name) |
| char? | file_separator () |
| void? | reduce_file_separators (cmt_string &text) |
| ? |
Transform all / or \ characters in the text into the current file_separator Reduce all multiple file_separator into single ones. |
| char? | path_separator () |
| char? | command_separator () |
| const cmt_string &? | ev_open () |
| const cmt_string &? | ev_close () |
| bool? | create_symlink (const cmt_string &oldname, const cmt_string &newname) |
| bool? | remove_file (const cmt_string &name) |
| bool? | remove_directory (const cmt_string &name) |
| bool? | mkdir (const cmt_string &name) |
| void? | scan_dir (const cmt_string &dir_name, cmt_string_vector &list) |
| void? | scan_dir (const cmt_string &dir_name, const cmt_regexp &expression, cmt_string_vector &list) |
| cmt_string_vector &? | scan_dir (const cmt_string &dir_name) |
| const cmt_string &? | get_cmt_root () |
| void? | get_cmt_version (cmt_string &version) |
| cmt_string? | get_cmt_config () |
| cmt_string? | get_cmt_site () |
| void? | get_uname (cmt_string &uname) |
| void? | get_hosttype (cmt_string &hosttype) |
| cmt_string? | get_temporary_name () |
| cmt_string? | get_home_package () |
| bool? | is_home_package (const cmt_string &name, const cmt_string &version) |
| cmt_string? | get_user_context_package () |
| bool? | is_user_context_package (const cmt_string &name, const cmt_string &version) |
| cmt_string? | get_project_package () |
| bool? | is_project_package (const cmt_string &name, const cmt_string &version) |
| bool? | testenv (const cmt_string &name) |
| cmt_string? | getenv (const cmt_string &name) |
| bool? | putenv (const cmt_string &name_value) |
| void? | add_cmt_path (const cmt_string &path, const cmt_string &path_source, IProjectFactory &factory) |
| void? | get_cmt_paths (IProjectFactory &factory, const cmt_string &init_text="") |
| int? | execute (const cmt_string &command) |
| int? | execute (const cmt_string &command, cmt_string &output) |
| bool? | is_package_directory (const cmt_string &name) |
| bool? | is_version_directory (const cmt_string &name) |
| bool? | is_version_directory (const cmt_string &name, int &v, int &r, int &p) |
| void? | split (const cmt_string &text, const cmt_string &separators, cmt_string_vector &strings) |
| void? | compress_path (const cmt_string &dir, cmt_string &new_dir) |
| void? | compress_path (cmt_string &dir) |
| cmt_string? | now () |
| cmt_string? | user () |
| void? | get_cvsroot (cmt_string &cvsroot) |
| bool? | get_home_directory (cmt_string &dir) |
|
| ? |
Definition at line 26 of file cmt_system.h. |
|
| ? |
Definition at line 253 of file cmt_system.cxx. References cmt_string::size(). Referenced by Symbol::action(), DependencyGenerator::build(), Use::build_library_links(), Use::change_path(), Cmt::do_create(), Cmt::do_remove(), Cmt::do_remove_library_links(), dos_script_prefix(), mkdir(), Use::move_to(), Use::reach_package(), constituents_action_iterator::set(), CmtGenerator::set_full_name(), and Use::show_all(). |
|
||||||||||||||||
| ? |
Definition at line 1227 of file cmt_system.cxx. References IProjectFactory::create_project(), file_separator(), CmtError::path_not_found, cmt_string::replace_all(), CmtError::set(), cmt_string::size(), and test_directory(). Referenced by add_cmt_paths_from_text(), get_cmt_paths(), and Cmt::parse_arguments(). 01230 {
01231 cmt_string npath = path;
01232
01233 if (npath == "") return;
01234
01235 #ifdef WIN32
01236 if (npath.size () == 2)
01237 {
01238 if (npath[1] == ':')
01239 {
01240 npath += file_separator ();
01241 }
01242 }
01243 #endif
01244
01245 npath.replace_all ("\\", file_separator ());
01246 npath.replace_all ("/", file_separator ());
01247
01248 if (!test_directory (npath))
01249 {
01250 CmtError::set (CmtError::path_not_found, npath);
01251 return;
01252 }
01253
01254 factory.create_project (path, path_source);
01255 }
|
|
||||||||||||||||
| ? |
Definition at line 142 of file cmt_system.cxx. References basename(), cmt_string::erase(), cmt_string::find_last_of(), and cmt_string::npos. 00145 {
00146 basename (file_name, result);
00147
00148 int pos;
00149
00150 pos = result.find_last_of ('.');
00151
00152 if (pos != cmt_string::npos)
00153 {
00154 result.erase (pos);
00155 }
00156 }
|
|
||||||||||||
| ? |
Definition at line 123 of file cmt_system.cxx. References cmt_string::find_last_of(), cmt_string::npos, and cmt_string::substr(). Referenced by DependencyFilter::add_source(), DocumentGenerator::analyze_file(), LibraryGenerator::analyze_file(), basename(), Prototyper::begin(), DependencyGenerator::build(), DocumentGenerator::build(), Use::build_library_links(), Generator::build_windefs(), CmtInstallAreaMgr::config(), Cmt::configure_current_package(), current_branch(), Cmt::do_broadcast(), CvsImplementation::do_checkout(), Cmt::do_config(), Cmt::do_remove_library_links(), Cmt::do_set_version(), CvsImplementation::find_matching_version(), get_cmt_version(), DependencyFilter::has_source(), LibraryGenerator::java_file_action(), Cmt::load(), LibraryGenerator::module_file_action(), LibraryGenerator::proto_file_action(), Cmt::reach_current_package(), Use::reach_package(), UseAnalyzer::run(), DepsBuilder::run(), FAwk::run(), scan_dir(), PathScanner::scan_package(), PathScanner::scan_path(), constituents_action_iterator::set(), Cmt::set_standard_macros(), and CvsImplementation::show_cvs_infos(). 00124 {
00125 int pos = file_name.find_last_of ('/');
00126 if (pos == cmt_string::npos)
00127 {
00128 pos = file_name.find_last_of ('\\');
00129 }
00130
00131 if (pos == cmt_string::npos)
00132 {
00133 result = file_name;
00134 }
00135 else
00136 {
00137 file_name.substr (pos + 1, result);
00138 }
00139 }
|
|
| ? |
Definition at line 85 of file cmt_system.cxx. References cmt_string::c_str(), file_separator(), putenv(), and cmt_string::size(). Referenced by Use::add(), Generator::build_windefs(), CvsImplementation::checkout_package(), Project::create(), ProjectFactory::create_project(), Cmt::do_broadcast(), CvsImplementation::do_checkout(), Cmt::do_config(), Cmt::do_create(), Cmt::do_remove(), Cmt::load(), Cmt::reach_current_package(), Use::reach_package(), CvsImplementation::really_checkout_package(), VSNETGenerator::reset(), MSDEVGenerator::reset(), CmtGenerator::reset(), same_dirs(), Use::select_alternate(), and CvsImplementation::show_cvs_infos(). 00086 {
00087 static cmt_string new_dir;
00088
00089 if ((dir.size () == 2) && (dir[1] == ':'))
00090 {
00091 new_dir = dir;
00092 new_dir += file_separator ();
00093 if (chdir (new_dir.c_str ()) == 0)
00094 {
00095 #ifdef USE_PWD
00096 new_dir = "PWD=";
00097 new_dir += dir;
00098 new_dir += file_separator ();
00099 putenv (new_dir);
00100 #endif
00101
00102 return (true);
00103 }
00104 return (false);
00105 }
00106 else
00107 {
00108 if (chdir (dir.c_str ()) == 0)
00109 {
00110 #ifdef USE_PWD
00111 new_dir = "PWD=";
00112 new_dir += dir;
00113 putenv (new_dir);
00114 #endif
00115
00116 return (true);
00117 }
00118 return (false);
00119 }
00120 }
|
|
| ? |
Definition at line 540 of file cmt_system.cxx. Referenced by SequenceRunner::filter(), and CvsImplementation::really_checkout_package(). 00541 {
00542 #ifdef WIN32
00543 return ('&');
00544 #else
00545 return (';');
00546 #endif
00547 }
|
|
||||||||||||
| ? |
Check if the file "name1" is identical to "name2" if they are identical, "name1" will be simply deleted otherwise "name1" will be copied to "name2" and deleted afterwards. Definition at line 409 of file cmt_system.cxx. References cmt_string::c_str(), and cmt_string::read(). Referenced by Cmt::do_check_files(), Cmt::install_cleanup_scripts(), Cmt::install_setup_scripts(), Cmt::install_test_cleanup_scripts(), and Cmt::install_test_setup_scripts(). 00411 {
00412 struct stat file_stat1;
00413 struct stat file_stat2;
00414 static cmt_string s1;
00415 static cmt_string s2;
00416 int status;
00417
00418 status = stat (name1.c_str (), &file_stat1);
00419
00420 if (status == 0)
00421 {
00422 if ((file_stat1.st_mode & S_IFDIR) != 0)
00423 {
00424 // name1 is a directory.
00425 return (false);
00426 }
00427 }
00428 else
00429 {
00430 // name1 does not exist
00431 return (false);
00432 }
00433
00434 s1.read (name1);
00435
00436 status = stat (name2.c_str (), &file_stat2);
00437
00438 if (status == 0)
00439 {
00440 if ((file_stat2.st_mode & S_IFDIR) != 0)
00441 {
00442 // name2 is a directory
00443 return (false);
00444 }
00445
00446 if (((int) file_stat1.st_size) == ((int) file_stat2.st_size))
00447 {
00448 s2.read (name2);
00449 if (s1 == s2)
00450 {
00451 unlink (name1);
00452 return (true);
00453 }
00454 }
00455 }
00456
00457 FILE* f = fopen (name2, "wb");
00458 if (f != NULL)
00459 {
00460 s1.write (f);
00461 fclose (f);
00462
00463 unlink (name1);
00464
00465 return (true);
00466 }
00467 else
00468 {
00469 //
00470 // keep the new file "name1" since it cannot be
00471 // copied to "name2"
00472 //
00473 return (false);
00474 }
00475 }
|
|
||||||||||||
| ? |
Check if the file "name1" is identical to "name2". Definition at line 353 of file cmt_system.cxx. References cmt_string::c_str(), and cmt_string::read(). Referenced by CmtGenerator::check(). 00355 {
00356 struct stat file_stat1;
00357 struct stat file_stat2;
00358 int status;
00359
00360 status = stat (name1.c_str (), &file_stat1);
00361
00362 if (status == 0)
00363 {
00364 if ((file_stat1.st_mode & S_IFDIR) != 0)
00365 {
00366 return (false);
00367 }
00368 }
00369 else
00370 {
00371 return (false);
00372 }
00373
00374 status = stat (name2.c_str (), &file_stat2);
00375
00376 if (status == 0)
00377 {
00378 if ((file_stat2.st_mode & S_IFDIR) != 0)
00379 {
00380 return (false);
00381 }
00382 }
00383 else
00384 {
00385 return (false);
00386 }
00387
00388 if (((int) file_stat1.st_size) != ((int) file_stat2.st_size))
00389 {
00390 return (false);
00391 }
00392
00393 static cmt_string s1;
00394 static cmt_string s2;
00395
00396 s1.read (name1);
00397 s2.read (name2);
00398
00399 return ((s1 == s2));
00400 }
|
|
| ? |
Definition at line 1940 of file cmt_system.cxx. References cmt_string::erase(), file_separator(), cmt_string::find(), cmt_string::find_last_of(), cmt_string::npos, cmt_string::replace_all(), cmt_string::size(), and cmt_string::substr(). 01941 {
01942 #ifdef WIN32
01943 static const char pattern[] = "\\..";
01944 //static const char here[] = ".\\";
01945 static const char fs[] = "\\\\";
01946 #else
01947 static const char pattern[] = "/..";
01948 //static const char here[] = "./";
01949 static const char fs[] = "//";
01950 #endif
01951
01952 if (dir.size () == 0) return;
01953
01954 //
01955 // We first synchronize to using file_separator() in any case.
01956 //
01957
01958 if (file_separator () == '/')
01959 {
01960 dir.replace_all ("\\", file_separator ());
01961 }
01962 else
01963 {
01964 dir.replace_all ("/", file_separator ());
01965 }
01966
01967 dir.replace_all (fs, file_separator ());
01968
01969 for (;;)
01970 {
01971 int pos1;
01972 int pos2;
01973
01974 pos1 = dir.find (pattern);
01975 if (pos1 == cmt_string::npos) break;
01976
01977 //
01978 // extract "aaaa/xxxx" from "aaaa/xxxx/../bbbb"
01979 //
01980 cmt_string p = dir.substr (0, pos1);
01981
01982 //
01983 // Is "aaaa/xxxx" only made of "xxxx" ?
01984 //
01985 pos2 = p.find_last_of (file_separator ());
01986
01987 if (pos2 == cmt_string::npos)
01988 {
01989 // the pattern was xxxx/..
01990 dir.erase (0, pos1 + 3);
01991 }
01992 else
01993 {
01994 // 01234567890123456
01995 // aaaa/xxxx/../bbbb
01996 // 2 1 3
01997 //
01998 // erase the "/xxxx/.." pattern
01999 // result will be "aaaa/bbbb"
02000 //
02001 dir.erase (pos2, pos1 + 3 - pos2);
02002 }
02003 }
02004
02005 //if (dir[dir.size () - 1] == file_separator ()) dir.erase (dir.size () - 1);
02006 }
|
|
||||||||||||
| ? |
Definition at line 1926 of file cmt_system.cxx. Referenced by DependencyGenerator::build(), DocumentGenerator::build(), LibraryGenerator::build(), Use::change_path(), ProjectFactory::create_project(), Cmt::do_create(), Cmt::do_remove(), Cmt::filter_dir(), CmtGenerator::filter_path(), Project::find_by_cmtpath(), Use::get_cmtpath_and_offset(), and PathScanner::scan_path(). 01927 {
01928 new_dir = dir;
01929
01930 compress_path (new_dir);
01931 }
|
|
||||||||||||
| ? |
Definition at line 574 of file cmt_system.cxx. References cmt_string::c_str(). Referenced by install_library(). |
|
| ? |
Definition at line 293 of file cmt_system.cxx. References basename(), and pwd(). Referenced by DependencyGenerator::build(), VSNETGenerator::reset(), MSDEVGenerator::reset(), and CmtGenerator::reset(). 00294 {
00295 cmt_string result;
00296
00297 basename (pwd (), result);
00298
00299 return (result);
00300 }
|
|
||||||||||||
| ? |
Definition at line 159 of file cmt_system.cxx. References cmt_string::erase(), cmt_string::find_last_of(), and cmt_string::npos. Referenced by DocumentGenerator::analyze_file(), DocumentGenerator::build(), build_deps(), Generator::build_windefs(), CmtInstallAreaMgr::config(), Cmt::configure_current_package(), Cmt::do_broadcast(), CvsImplementation::do_checkout(), Cmt::do_set_version(), SequenceRunner::filter(), CvsImplementation::find_matching_version(), get_cmt_root(), Use::get_cmtpath_and_offset(), install_library(), Cmt::load(), LibraryGenerator::module_file_action(), LibraryGenerator::proto_file_action(), Cmt::reach_current_package(), CvsImplementation::really_checkout_package(), DepsBuilder::run(), FAwk::run(), scan_dir(), PathScanner::scan_path(), constituents_action_iterator::set(), and Cmt::set_standard_macros(). 00160 {
00161 int pos = file_name.find_last_of ('/');
00162 if (pos == cmt_string::npos)
00163 {
00164 pos = file_name.find_last_of ('\\');
00165 }
00166
00167 if (pos == cmt_string::npos)
00168 {
00169 result = "";
00170 }
00171 else
00172 {
00173 result = file_name;
00174 result.erase (pos);
00175 }
00176 }
|
|
| ? |
Definition at line 562 of file cmt_system.cxx. Referenced by resolve_value_for_macros(). 00563 {
00564 #ifdef WIN32
00565 static const cmt_string s = "%";
00566 #else
00567 static const cmt_string s = "}";
00568 #endif
00569
00570 return (s);
00571 }
|
|
| ? |
Definition at line 550 of file cmt_system.cxx. Referenced by resolve_value_for_macros(). 00551 {
00552 #ifdef WIN32
00553 static const cmt_string s = "%";
00554 #else
00555 static const cmt_string s = "${";
00556 #endif
00557
00558 return (s);
00559 }
|
|
||||||||||||
| ? |
Definition at line 1436 of file cmt_system.cxx. References cmt_string::c_str(). 01437 {
01438 output = "";
01439
01440 //cout << "CmtSystem::execute2> [" << command << "]" << endl;
01441
01442 FILE* f = popen (command.c_str (), "r");
01443
01444 if (f != 0)
01445 {
01446 char line[256];
01447 char* ptr;
01448
01449 while ((ptr = fgets (line, sizeof (line), f)) != NULL)
01450 {
01451 output += ptr;
01452 }
01453 pclose (f);
01454
01455 return (0);
01456 }
01457
01458 return (1);
01459 }
|
|
| ? |
Definition at line 1428 of file cmt_system.cxx. References cmt_string::c_str(). Referenced by DependencyAnalyzer::DependencyAnalyzer(), Cmt::do_broadcast(), CvsImplementation::do_checkout(), Cmt::do_do(), Cmt::do_remove_library_links(), Cmt::do_run(), SequenceRunner::filter(), install_library(), CmtLock::lock(), CvsImplementation::really_checkout_package(), resolve_value(), resolve_value_for_macros(), DepsBuilder::run(), CvsImplementation::show_cvs_infos(), suppress_OS_delimiters(), and CmtLock::unlock(). 01429 {
01430 //cout << "CmtSystem::execute1> [" << command << "]" << endl;
01431
01432 return (system (command.c_str ()));
01433 }
|
|
| ? |
Definition at line 496 of file cmt_system.cxx. Referenced by Symbol::action(), DepsBuilder::add(), add_cmt_path(), DepsBuilder::add_includes(), DocumentGenerator::analyze_file(), LibraryGenerator::analyze_file(), SequenceRunner::begin(), Prototyper::begin(), DependencyGenerator::build(), MakeSetupGenerator::build(), ReadmeGenerator::build(), DocumentGenerator::build(), build_deps(), CvsImplementation::build_version_directory(), cd(), Use::change_path(), CvsImplementation::checkout_package(), compress_path(), CmtInstallAreaMgr::config(), Cmt::configure_current_cmtpath(), Cmt::configure_current_dir(), Cmt::configure_current_package(), Cmt::configure_default_path(), Cmt::do_broadcast(), Cmt::do_build_CMT_pacman(), Cmt::do_build_library_links(), CvsImplementation::do_checkout(), Cmt::do_create(), SyntaxParser::do_parse_requirements(), Cmt::do_remove(), Cmt::do_remove_library_links(), Use::fill_includes_macro(), Use::fill_standard_macros(), DependencyAnalyzer::filter(), SequenceRunner::filter(), Packager::filter(), CvsImplementation::find_matching_version(), get_best_form(), get_cmt_paths(), Use::get_cmtpath_and_offset(), get_dot_suffix(), Use::get_full_path(), get_suffix(), header_file_action(), install_library(), is_package_directory(), Cmt::load(), Fragment::locate(), mkdir(), LibraryGenerator::module_file_action(), CmtGenerator::prepare_use_context(), Cmt::print_context(), LibraryGenerator::proto_file_action(), Cmt::reach_current_package(), Use::reach_package(), CvsImplementation::really_checkout_package(), reduce_file_separators(), Use::reduce_path(), VSNETGenerator::reset(), MSDEVGenerator::reset(), CmtGenerator::reset(), UseAnalyzer::run(), ClientCollector::run(), PackageSelector::run(), scan_dir(), PathScanner::scan_package(), PathScanner::scan_path(), constituents_action_iterator::set(), CmtGenerator::set_full_name(), Cmt::set_standard_macros(), CmtInstallAreaMgr::setup_current_installarea(), CvsImplementation::show_cvs_infos(), StandardMacroBuilder::StandardMacroBuilder(), and Cmt::use_special_requirements(). 00497 {
00498 #ifdef WIN32
00499 return ('\\');
00500 #else
00501 return ('/');
00502 #endif
00503 }
|
|
| ? |
Definition at line 478 of file cmt_system.cxx. References cmt_string::c_str(). 00479 {
00480 struct stat file_stat;
00481 int status;
00482
00483 status = stat (name.c_str (), &file_stat);
00484
00485 if (status == 0)
00486 {
00487 return ((int) file_stat.st_size);
00488 }
00489 else
00490 {
00491 return (0);
00492 }
00493 }
|
|
| ? |
Definition at line 995 of file cmt_system.cxx. Referenced by Cmt::configure_config_tag(), Cmt::do_show_system(), getenv(), Cmt::parse_arguments(), and Cmt::print_context(). 00996 {
00997 const char* env = ::getenv ("CMTCONFIG");
00998 if (env != 0)
00999 {
01000 return (cmt_string (env));
01001 }
01002
01003 env = ::getenv ("CMTBIN");
01004 if (env != 0)
01005 {
01006 return (cmt_string (env));
01007 }
01008
01009 #ifdef WIN32
01010 LONG status;
01011 HKEY key = 0;
01012
01013 status = RegOpenKeyEx (HKEY_LOCAL_MACHINE, "Software\\CMT",
01014 0, KEY_READ, &key);
01015 if (status == ERROR_SUCCESS)
01016 {
01017 char temp[256];
01018 DWORD length = sizeof (temp) - 1;
01019 DWORD type;
01020
01021 status = RegQueryValueEx (key, "config", 0, &type,
01022 (LPBYTE) temp, &length);
01023 if (status == ERROR_SUCCESS)
01024 {
01025 cmt_string config (temp);
01026 return (config);
01027 }
01028 }
01029
01030 return ("VisualC");
01031 #endif
01032
01033 return ("");
01034
01035 }
|
|
||||||||||||
| ? |
Definition at line 1300 of file cmt_system.cxx. References add_cmt_path(), add_cmt_paths(), add_cmt_paths_from_text(), file_separator(), get_cmt_root(), get_cmt_version(), get_home_directory(), getenv(), name(), path_separator(), cmt_vector< cmt_string >::size(), and split(). Referenced by Cmt::configure_cmt_path(). 01301 {
01302 if (init_text != "")
01303 {
01304 add_cmt_paths_from_text (init_text, "initialization", factory);
01305 }
01306
01307 #ifdef WIN32
01308 LONG status;
01309 HKEY key = 0;
01310
01311 status = RegOpenKeyEx (HKEY_CURRENT_USER, "Software\\CMT\\path",
01312 0, KEY_READ, &key);
01313 if (status == ERROR_SUCCESS)
01314 {
01315 DWORD index = 0;
01316 char name[256];
01317 char temp[256];
01318
01319 for (;;)
01320 {
01321 DWORD name_length = sizeof (name) - 1;
01322 DWORD length = sizeof (temp) - 1;
01323 DWORD type;
01324 status = RegEnumValue (key, index,
01325 name, &name_length, 0, &type,
01326 (LPBYTE) temp, &length);
01327 if ((status == ERROR_SUCCESS) ||
01328 (status == 234))
01329 {
01330 const cmt_string path = temp;
01331 add_cmt_path (path, "HKEY_CURRENT_USER", factory);
01332 }
01333
01334 if (status == 259)
01335 {
01336 break;
01337 }
01338
01339 index++;
01340 }
01341 }
01342
01343 status = RegOpenKeyEx (HKEY_LOCAL_MACHINE, "Software\\CMT\\path",
01344 0, KEY_READ, &key);
01345 if (status == ERROR_SUCCESS)
01346 {
01347 DWORD index = 0;
01348 char name[256];
01349 char temp[256];
01350
01351 for (;;)
01352 {
01353 DWORD type;
01354 DWORD name_length = sizeof (name) - 1;
01355 DWORD length = sizeof (temp) - 1;
01356
01357
01358 status = RegEnumValue (key, index,
01359 name, &name_length, 0, &type,
01360 (LPBYTE) temp, &length);
01361 if (status != ERROR_NO_MORE_ITEMS)
01362 {
01363 const cmt_string path = temp;
01364 add_cmt_path (path, "HKEY_LOCAL_MACHINE", factory);
01365 }
01366 else
01367 {
01368 break;
01369 }
01370 index++;
01371 }
01372 }
01373
01374 #endif
01375
01376 //-----------------------------------------
01377 // look for .cmtrc files :
01378 // first look in ./
01379 // then in "~/"
01380 // then in ${CMTROOT}/mgr
01381 //-----------------------------------------
01382 cmt_string rc_name;
01383
01384 const cmt_string env = CmtSystem::getenv ("CMTPATH");
01385
01386 if (env != "")
01387 {
01388 static cmt_string_vector path_vector;
01389 int i;
01390
01391 split (env, path_separator (), path_vector);
01392
01393 for (i = 0; i < path_vector.size (); i++)
01394 {
01395 const cmt_string& path = path_vector[i];
01396
01397 add_cmt_path (path, "${CMTPATH}", factory);
01398 }
01399 }
01400
01401 add_cmt_paths (".cmtrc", factory);
01402
01403 if (get_home_directory (rc_name))
01404 {
01405 rc_name += file_separator ();
01406 rc_name += ".cmtrc";
01407 add_cmt_paths (rc_name, factory);
01408 }
01409
01410 rc_name = get_cmt_root ();
01411 rc_name += file_separator ();
01412 rc_name += "CMT";
01413 rc_name += file_separator ();
01414 cmt_string version;
01415 get_cmt_version (version);
01416 rc_name += version;
01417 rc_name += file_separator ();
01418 rc_name += "mgr";
01419 rc_name += file_separator ();
01420 rc_name += ".cmtrc";
01421
01422 add_cmt_paths (rc_name, factory);
01423
01424 add_cmt_path (get_cmt_root (), "default path", factory);
01425 }
|
|
| ? |
Definition at line 918 of file cmt_system.cxx. References dirname(). Referenced by Cmt::configure_default_path(), and get_cmt_paths(). 00919 {
00920 static cmt_string root;
00921
00922 root = "";
00923
00924 const char* env = ::getenv ("CMTROOT");
00925 if (env != 0)
00926 {
00927 root = env;
00928
00929 dirname (root, root);
00930 dirname (root, root);
00931 return (root);
00932 }
00933
00934 #ifdef WIN32
00935 LONG status;
00936 HKEY key = 0;
00937
00938 status = RegOpenKeyEx (HKEY_LOCAL_MACHINE, "Software\\CMT",
00939 0, KEY_READ, &key);
00940 if (status == ERROR_SUCCESS)
00941 {
00942 char temp[256];
00943 DWORD length = sizeof (temp) - 1;
00944 DWORD type;
00945
00946 status = RegQueryValueEx (key, "root", 0, &type, (LPBYTE) temp, &length);
00947 if (status == ERROR_SUCCESS)
00948 {
00949 root = temp;
00950 return (root);
00951 }
00952 }
00953 #endif
00954
00955 return (root);
00956 }
|
|
| ? |
Definition at line 1038 of file cmt_system.cxx. Referenced by Cmt::configure_site_tag(). 01039 {
01040 const char* env = ::getenv ("CMTSITE");
01041 if (env != 0)
01042 {
01043 return (cmt_string (env));
01044 }
01045
01046 #ifdef WIN32
01047 LONG status;
01048 HKEY key = 0;
01049
01050 status = RegOpenKeyEx (HKEY_LOCAL_MACHINE, "Software\\CMT",
01051 0, KEY_READ, &key);
01052 if (status == ERROR_SUCCESS)
01053 {
01054 char temp[256];
01055 DWORD length = sizeof (temp) - 1;
01056 DWORD type;
01057
01058 status = RegQueryValueEx (key, "site", 0, &type, (LPBYTE) temp, &length);
01059 if (status == ERROR_SUCCESS)
01060 {
01061 cmt_string site (temp);
01062 return (site);
01063 }
01064 }
01065 #endif
01066
01067 return ("");
01068 }
|
|
| ? |
Definition at line 959 of file cmt_system.cxx. References basename(). Referenced by Cmt::configure_default_path(), and get_cmt_paths(). 00960 {
00961 version = "";
00962
00963 const char* env = ::getenv ("CMTROOT");
00964 if (env != 0)
00965 {
00966 cmt_string s = env;
00967 basename (s, version);
00968 }
00969 else
00970 {
00971 #ifdef WIN32
00972 LONG status;
00973 HKEY key = 0;
00974
00975 status = RegOpenKeyEx (HKEY_LOCAL_MACHINE, "Software\\CMT",
00976 0, KEY_READ, &key);
00977 if (status == ERROR_SUCCESS)
00978 {
00979 char temp[256];
00980 DWORD length = sizeof (temp) - 1;
00981 DWORD type;
00982
00983 status = RegQueryValueEx (key, "version", 0, &type,
00984 (LPBYTE) temp, &length);
00985 if (status == ERROR_SUCCESS)
00986 {
00987 version = temp;
00988 }
00989 }
00990 #endif
00991 }
00992 }
|
|
| ? |
Definition at line 2035 of file cmt_system.cxx. Referenced by CvsImplementation::really_checkout_package(), and CvsImplementation::show_cvs_infos(). 02036 {
02037 cvsroot = "";
02038
02039 const char* env = ::getenv ("CVSROOT");
02040 if (env != 0)
02041 {
02042 cvsroot = env;
02043 return;
02044 }
02045
02046 #ifdef WIN32
02047 LONG status;
02048 HKEY key = 0;
02049
02050 status = RegOpenKeyEx (HKEY_LOCAL_MACHINE, "Software\\CMT",
02051 0, KEY_READ, &key);
02052 if (status == ERROR_SUCCESS)
02053 {
02054 char temp[256];
02055 DWORD length = sizeof (temp) - 1;
02056 DWORD type;
02057
02058 status = RegQueryValueEx (key, "CVSROOT", 0, &type,
02059 (LPBYTE) temp, &length);
02060 if (status == ERROR_SUCCESS)
02061 {
02062 cvsroot = temp;
02063 return;
02064 }
02065 }
02066 #endif
02067 }
|
|
||||||||||||
| ? |
Definition at line 225 of file cmt_system.cxx. References file_separator(), cmt_string::find_last_of(), cmt_string::npos, and cmt_string::substr(). Referenced by DependencyFilter::add_source(), Prototyper::begin(), DependencyGenerator::build(), DocumentGenerator::build(), Generator::build_windefs(), CmtGenerator::get_all_files(), DependencyFilter::has_source(), LibraryGenerator::java_file_action(), LibraryGenerator::module_file_action(), and LibraryGenerator::proto_file_action(). 00226 {
00227 int pos = file.find_last_of ('.');
00228 int sep = file.find_last_of (file_separator ());
00229
00230 if ((pos == cmt_string::npos) || (pos < sep))
00231 {
00232 result = "";
00233 }
00234 else
00235 {
00236 file.substr (pos, result);
00237 }
00238 }
|
|
| ? |
Definition at line 2070 of file cmt_system.cxx. Referenced by Cmt::configure_current_dir(), and get_cmt_paths(). 02071 {
02072 bool status = false;
02073
02074 #ifdef WIN32
02075 const char* homedrive = ::getenv ("HOMEDRIVE");
02076 const char* homepath = ::getenv ("HOMEPATH");
02077
02078 if ((homedrive != 0) && (homepath != 0))
02079 {
02080 dir = homedrive;
02081 dir += homepath;
02082 status = true;
02083 }
02084
02085 #else
02086 const char* home_env = ::getenv ("HOME");
02087 if (home_env != 0)
02088 {
02089 dir = home_env;
02090 status = true;
02091 }
02092 #endif
02093
02094 return (status);
02095 }
|
|
| ? |
Definition at line 1128 of file cmt_system.cxx. References name(). Referenced by Use::add(), Use::get_cmtpath_and_offset(), Use::reach_package(), Use::show_all(), and Cmt::use_home_requirements(). 01129 {
01130 cmt_string name = "CMTHOME";
01131
01132 return (name);
01133 }
|
|
| ? |
Definition at line 1104 of file cmt_system.cxx. Referenced by Cmt::configure_hosttype_tag(). 01105 {
01106 hosttype = "";
01107
01108 char* ptr;
01109
01110 ptr = ::getenv ("HOSTTYPE");
01111 if (ptr != 0)
01112 {
01113 hosttype = ptr;
01114 }
01115 }
|
|
| ? |
Definition at line 1162 of file cmt_system.cxx. References name(). Referenced by Use::add(), Use::get_cmtpath_and_offset(), and Use::reach_package(). 01163 {
01164 cmt_string name = "PROJECT";
01165
01166 return (name);
01167 }
|
|
||||||||||||
| ? |
Definition at line 209 of file cmt_system.cxx. References file_separator(), cmt_string::find_last_of(), cmt_string::npos, and cmt_string::substr(). Referenced by DependencyFilter::add_source(), DocumentGenerator::analyze_file(), LibraryGenerator::analyze_file(), DependencyGenerator::build(), DocumentGenerator::build(), DependencyFilter::has_source(), and LibraryGenerator::module_file_action(). 00210 {
00211 int pos = file.find_last_of ('.');
00212 int sep = file.find_last_of (file_separator ());
00213
00214 if ((pos == cmt_string::npos) || (pos < sep))
00215 {
00216 result = "";
00217 }
00218 else
00219 {
00220 file.substr (pos + 1, result);
00221 }
00222 }
|
|
| ? |
Definition at line 1118 of file cmt_system.cxx. References name(). Referenced by Cmt::do_build_temporary_name(), and CvsImplementation::show_cvs_infos(). 01119 {
01120 cmt_string name;
01121
01122 name = ::tmpnam (NULL);
01123
01124 return (name);
01125 }
|
|
| ? |
Definition at line 1071 of file cmt_system.cxx. Referenced by Cmt::configure_tags(), and Cmt::configure_uname_tag(). 01072 {
01073 #ifdef WIN32
01074 uname = "WIN32";
01075 #else
01076
01077 uname = "";
01078
01079 FILE* file;
01080
01081 file = popen ("uname", "r");
01082
01083 if (file != 0)
01084 {
01085 char line[1024];
01086 char* ptr;
01087 char* nl;
01088
01089 line[0] = 0;
01090 ptr = fgets (line, sizeof (line), file);
01091 if (ptr != 0)
01092 {
01093 nl = strrchr (ptr, '\n');
01094 if (nl != 0) *nl = 0;
01095
01096 uname = ptr;
01097 }
01098 pclose (file);
01099 }
01100 #endif
01101 }
|
|
| ? |
Definition at line 1145 of file cmt_system.cxx. References name(). Referenced by Use::add(), Use::get_cmtpath_and_offset(), Use::reach_package(), Use::show_all(), and Cmt::use_user_context_requirements(). 01146 {
01147 cmt_string name = "CMTUSERCONTEXT";
01148
01149 return (name);
01150 }
|
|
| ? |
Definition at line 1187 of file cmt_system.cxx. References get_cmt_config(). Referenced by DepsBuilder::add_includes(), SequenceRunner::begin(), CvsImplementation::branches(), PathBuilder::build(), SetBuilder::build(), DependencyGenerator::build(), CvsImplementation::checkout(), PathBuilder::clean(), Cmt::configure_current_structuring_style(), Cmt::configure_home(), Cmt::configure_tags(), Cmt::configure_user_context(), PatternCache::do_update(), SequenceRunner::filter(), get_cmt_paths(), BestFitSelector::operate(), Cmt::reach_current_package(), CvsImplementation::really_checkout_package(), resolve_value(), Cmt::restore_all_tags(), Cmt::set_standard_macros(), CvsImplementation::show_cvs_infos(), CvsImplementation::subpackages(), CvsImplementation::tags(), user(), and Fragment::wincopy(). 01188 {
01189 cmt_string result;
01190
01191 const char* env = ::getenv (name);
01192 if (env != 0)
01193 {
01194 result = env;
01195 }
01196
01197 if (name == "CMTCONFIG")
01198 {
01199 return (get_cmt_config ());
01200 }
01201
01202 /*
01203 if (name == "CMTROOT")
01204 {
01205 return (get_cmt_root ());
01206 }
01207
01208 if (name == "CMTSITE")
01209 {
01210 return (get_cmt_site ());
01211 }
01212 */
01213
01214 return (result);
01215 }
|
|
| ? |
Definition at line 271 of file cmt_system.cxx. References cmt_string::size(). Referenced by mkdir(). 00272 {
00273 #ifdef WIN32
00274 if (name.size () == 0) return (false);
00275
00276 if (name.size () >= 2)
00277 {
00278 if (name[1] == ':')
00279 {
00280 return (true);
00281 }
00282 else if ((name[0] == '\\') && (name[1] == '\\'))
00283 {
00284 return (true);
00285 }
00286 }
00287 #endif
00288
00289 return (false);
00290 }
|
|
| ? |
Definition at line 241 of file cmt_system.cxx. References cmt_string::find(), and cmt_string::npos. 00242 {
00243 if ((name.find ('/') == cmt_string::npos) &&
00244 (name.find ('\\') == cmt_string::npos))
00245 {
00246 return (false);
00247 }
00248
00249 return (true);
00250 }
|
|
||||||||||||
| ? |
Definition at line 1136 of file cmt_system.cxx. Referenced by use_action_iterator::ok(). 01138 {
01139 if (name == "CMTHOME") return (true);
01140
01141 return (false);
01142 }
|
|
| ? |
Definition at line 1462 of file cmt_system.cxx. References file_separator(), scan_dir(), cmt_vector< cmt_string >::size(), and test_file(). 01463 {
01464 cmt_string_vector dirs;
01465
01466 cmt_regexp exp ("^[a-zA-Z.][0-9]+([a-zA-Z.][0-9]+([a-zA-Z.][0-9]+)?)?");
01467
01468 scan_dir (name, exp, dirs);
01469
01470 cmt_string req;
01471
01472 req = name;
01473 req += file_separator ();
01474 req += "cmt";
01475 req += file_separator ();
01476 req += "requirements";
01477
01478 if (test_file (req)) return (true);
01479
01480 if (dirs.size () == 0)
01481 {
01482 return (false);
01483 }
01484
01485 for (int i = 0; i < dirs.size (); i++)
01486 {
01487 const cmt_string& d = dirs[i];
01488
01489 req = d;
01490 req += file_separator ();
01491 req += "mgr";
01492 req += file_separator ();
01493 req += "requirements";
01494
01495 if (test_file (req)) return (true);
01496
01497 req = d;
01498 req += file_separator ();
01499 req += "cmt";
01500 req += file_separator ();
01501 req += "requirements";
01502
01503 if (test_file (req)) return (true);
01504 }
01505
01506 return (false);
01507 }
|
|
||||||||||||
| ? |
Definition at line 1170 of file cmt_system.cxx. Referenced by use_action_iterator::ok(). 01172 {
01173 if (name == "PROJECT") return (true);
01174
01175 return (false);
01176 }
|
|
||||||||||||
| ? |
Definition at line 1153 of file cmt_system.cxx. Referenced by use_action_iterator::ok(). 01155 {
01156 if (name == "CMTUSERCONTEXT") return (true);
01157
01158 return (false);
01159 }
|
|
||||||||||||||||||||
| ? |
Definition at line 1520 of file cmt_system.cxx. References cmt_string::c_str(), cmt_string::find(), cmt_string::npos, and cmt_string::size(). 01524 {
01525 static const cmt_string numbers = "0123456789";
01526
01527 static const int id_version = 0;
01528 static const int id_release = 1;
01529 static const int id_patch = 2;
01530
01531 cmt_string buffer;
01532
01533 enum
01534 {
01535 starting,
01536 at_key,
01537 at_number
01538 } state;
01539
01540 int id;
01541 int pos;
01542 int value;
01543
01544 v = 0;
01545 r = 0;
01546 p = 0;
01547
01548 //
01549 // version : v-field
01550 // | v-field r-field
01551 // | v-field r-field p-field
01552 //
01553 // v-field : field
01554 // r-field : field
01555 // p-field : field
01556 //
01557 // field : key '*'
01558 // | key number
01559 //
01560 // key : letters
01561 //
01562
01563 state = starting;
01564 id = id_version;
01565
01566 for (pos = 0; pos < name.size (); pos++)
01567 {
01568 char c = name[pos];
01569
01570 if (c == '*')
01571 {
01572 // A wild card
01573 switch (state)
01574 {
01575 case starting:
01576 // cannot start with a wild card ??
01577 v = -1;
01578 r = -1;
01579 p = -1;
01580 return (false);
01581 case at_key:
01582 // the numeric field is valued with a wild card
01583 switch (id)
01584 {
01585 case id_version:
01586 v = -1;
01587 case id_release:
01588 r = -1;
01589 case id_patch:
01590 p = -1;
01591 break;
01592 }
01593 return (true);
01594 case at_number:
01595 // question:
01596 // a number followed by a wild-card is considered as:
01597 // 1) a wild card on the number itself (1* comp with 1, 10, 12, 120, etc)
01598 // 2) a wild card on the next fields (1* comp with 1r1, 1-12 etc)
01599 //
01600
01601 // Here we select option 1)
01602
01603 sscanf (buffer.c_str (), "%d", &value);
01604 switch (id)
01605 {
01606 case id_version:
01607 //
01608 // lazy option 1 implies v = -1;
01609 // strict option 1 would imply v = -value;
01610 // option 2 implies v = value;
01611 //
01612
01613 v = -1;
01614 r = -1;
01615 p = -1;
01616 break;
01617 case id_release:
01618 r = value;
01619 p = -1;
01620 break;
01621 case id_patch:
01622 p = value;
01623 break;
01624 }
01625
01626 return (true);
01627 }
01628 }
01629 else if (numbers.find (c) == cmt_string::npos)
01630 {
01631 // A letter
01632 switch (state)
01633 {
01634 case starting:
01635 state = at_key;
01636 break;
01637 case at_key:
01638 // Multiple letter key (is it permitted??)
01639 break;
01640 case at_number:
01641 sscanf (buffer.c_str (), "%d", &value);
01642 switch (id)
01643 {
01644 case id_version:
01645 v = value;
01646 break;
01647 case id_release:
01648 r = value;
01649 break;
01650 case id_patch:
01651 p = value;
01652 break;
01653 }
01654 buffer = "";
01655 id++;
01656 state = at_key;
01657 break;
01658 }
01659 }
01660 else
01661 {
01662 // a number
01663 switch (state)
01664 {
01665 case starting:
01666 // not starting by a letter (syntax error)
01667 return (false);
01668 case at_key:
01669 // the numeric field for the current id is starting now
01670 buffer += c;
01671 state = at_number;
01672 break;
01673 case at_number:
01674 // continuing the current numeric field
01675 buffer += c;
01676 break;
01677 }
01678 }
01679 }
01680
01681 switch (state)
01682 {
01683 case starting:
01684 // Empty version string
01685 return (false);
01686 case at_key:
01687 // Syntax error (when only letters. Ending letters is not an error)
01688 if (id == id_version) return (false);
01689 else return (true);
01690 case at_number:
01691 sscanf (buffer.c_str (), "%d", &value);
01692 switch (id)
01693 {
01694 case id_version:
01695 v = value;
01696 break;
01697 case id_release:
01698 r = value;
01699 break;
01700 case id_patch:
01701 p = value;
01702 break;
01703 }
01704 id++;
01705 state = at_key;
01706 return (true);
01707 }
01708
01709 return (false);
01710 }
|
|
| ? |
Definition at line 1510 of file cmt_system.cxx. Referenced by compare_versions(), Cmt::configure_current_package(), Cmt::configure_version_tag(), Cmt::do_check_version(), Cmt::do_set_version(), BestFitSelector::operate(), Cmt::reach_current_package(), Use::reach_package(), PathScanner::scan_package(), PathScanner::scan_path(), Use::select_alternate(), and Cmt::set_standard_macros(). 01511 {
01512 int v;
01513 int r;
01514 int p;
01515
01516 return (is_version_directory (name, v, r, p));
01517 }
|
|
| ? |
Definition at line 635 of file cmt_system.cxx. References absolute_path(), cmt_string::c_str(), file_separator(), has_device(), cmt_string::replace_all(), cmt_vector< cmt_string >::size(), split(), and test_directory(). Referenced by Project::create(), Cmt::do_build_library_links(), Cmt::do_config(), Cmt::do_create(), SequenceRunner::filter(), CvsImplementation::really_checkout_package(), VSNETGenerator::reset(), MSDEVGenerator::reset(), and CvsImplementation::show_cvs_infos(). 00636 {
00637 static cmt_string_vector path_vector;
00638 int i;
00639 static cmt_string full_path;
00640 char double_fs[] = " ";
00641
00642 double_fs[0] = file_separator ();
00643 double_fs[1] = file_separator ();
00644
00645 full_path = name;
00646
00647 if (file_separator () == '/')
00648 {
00649 full_path.replace_all ("\\", file_separator ());
00650 }
00651 else
00652 {
00653 full_path.replace_all ("/", file_separator ());
00654 }
00655
00656 full_path.replace_all (double_fs, file_separator ());
00657
00658 split (full_path, file_separator (), path_vector);
00659
00660 full_path = "";
00661
00662 if (absolute_path (name))
00663 {
00664 if (!has_device (name))
00665 {
00666 full_path = file_separator ();
00667 }
00668 }
00669
00670 for (i = 0; i < path_vector.size (); i++)
00671 {
00672 const cmt_string& path = path_vector[i];
00673
00674 if (i > 0) full_path += file_separator ();
00675 full_path += path;
00676
00677 if (has_device (path)) continue;
00678
00679 if (!test_directory (full_path))
00680 {
00681 #ifdef WIN32
00682 if (::_mkdir (full_path.c_str ()) != 0)
00683 {
00684 // cerr << "CMT> cannot create directory " << full_path << endl;
00685 return (false);
00686 }
00687 #else
00688 if (::mkdir (full_path.c_str (), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH ) != 0)
00689 {
00690 // cerr << "CMT> cannot create directory " << full_path << endl;
00691 return (false);
00692 }
00693 #endif
00694 }
00695 }
00696
00697 return (true);
00698 }
|
|
||||||||||||
| ? |
Definition at line 179 of file cmt_system.cxx. References cmt_string::erase(), cmt_string::find_last_of(), and cmt_string::npos. Referenced by get_cmt_paths(), get_home_package(), get_project_package(), get_temporary_name(), get_user_context_package(), LibraryGenerator::prepare_proto_file(), and scan_dir(). 00180 {
00181 int pos;
00182
00183 result = file_name;
00184
00185 // remove the suffix
00186
00187 pos = result.find_last_of ('.');
00188
00189 if (pos != cmt_string::npos)
00190 {
00191 result.erase (pos);
00192 }
00193
00194 // remove the directory name
00195
00196 pos = result.find_last_of ('/');
00197 if (pos == cmt_string::npos)
00198 {
00199 pos = result.find_last_of ('\\');
00200 }
00201
00202 if (pos != cmt_string::npos)
00203 {
00204 result.erase (0, pos + 1);
00205 }
00206 }
|
|
| ? |
Definition at line 2009 of file cmt_system.cxx. References cmt_string::replace_all(). Referenced by ReadmeGenerator::build(), DocumentGenerator::build(), LibraryGenerator::build(), and CmtLock::lock(). 02010 {
02011 cmt_string result;
02012
02013 time_t ltime;
02014 time (<ime);
02015 result = ctime (<ime);
02016
02017 result.replace_all ("\n", "");
02018
02019 return (result);
02020 }
|
|
| ? |
Definition at line 530 of file cmt_system.cxx. Referenced by add_cmt_paths_from_text(), PathBuilder::build(), PathBuilder::clean(), find_path_entry(), get_cmt_paths(), and Project::show_paths(). 00531 {
00532 #ifdef WIN32
00533 return (';');
00534 #else
00535 return (':');
00536 #endif
00537 }
|
|
| ? |
Definition at line 1218 of file cmt_system.cxx. References cmt_string::c_str(). Referenced by Symbol::all_set(), and cd(). 01219 {
01220 int status = ::putenv ((char*) name_value.c_str ());
01221
01222 if (status == 0) return (true);
01223 else return (false);
01224 }
|
|
| ? |
Definition at line 61 of file cmt_system.cxx. Referenced by Use::add(), DefaultMakefileGenerator::build(), CmtInstallAreaMgr::build_current_installarea(), CvsImplementation::checkout(), Cmt::configure_current_package(), ProjectFactory::create_project(), current_branch(), Cmt::do_broadcast(), Cmt::do_config(), Cmt::do_create(), Cmt::do_remove(), Cmt::do_set_version(), Project::find_in_cmt_paths(), CmtGenerator::get_all_files(), Project::get_current(), Use::get_full_path(), Cmt::load(), Cmt::parser(), Cmt::reach_current_package(), CmtMountFilterParser::reset(), CmtGenerator::reset(), same_dirs(), Cmt::set_standard_macros(), Project::show(), CvsImplementation::show_cvs_infos(), and StandardMacroBuilder::StandardMacroBuilder(). 00062 {
00063 char buffer[256] = "";
00064 char* ptr = 0;
00065 char* pwd_env = 0;
00066
00067 #ifdef USE_PWD
00068 pwd_env = ::getenv ("PWD");
00069 #endif
00070
00071 if (pwd_env != 0)
00072 {
00073 strcpy (buffer, pwd_env);
00074 }
00075 else
00076 {
00077 ptr = getcwd (buffer, sizeof (buffer));
00078 }
00079
00080 const char* t = &buffer[0];
00081 return ((cmt_string) t);
00082 }
|
|
| ? |
Transform all / or \ characters in the text into the current file_separator Reduce all multiple file_separator into single ones. Definition at line 509 of file cmt_system.cxx. References file_separator(), cmt_string::find(), cmt_string::npos, and cmt_string::replace_all(). Referenced by CvsImplementation::build_version_directory(), CvsImplementation::do_checkout(), CmtGenerator::prepare_use_context(), SourceFile::set(), and CmtGenerator::set_full_name(). 00510 {
00511 if (file_separator () == '/')
00512 {
00513 text.replace_all ("\\", "/");
00514 while (text.find ("//") != cmt_string::npos)
00515 {
00516 text.replace_all ("//", "/");
00517 }
00518 }
00519 else
00520 {
00521 text.replace_all ("/", "\\");
00522 while (text.find ("\\\\") != cmt_string::npos)
00523 {
00524 text.replace_all ("\\\\", "\\");
00525 }
00526 }
00527 }
|
|
| ? |
Definition at line 602 of file cmt_system.cxx. References remove_file(), scan_dir(), cmt_vector< cmt_string >::size(), and test_directory(). Referenced by Cmt::do_remove(), and CvsImplementation::show_cvs_infos(). 00603 {
00604 //cout << "Try to remove directory " << name << endl;
00605
00606 cmt_string_vector files;
00607
00608 scan_dir (name, files);
00609
00610 for (int i = 0; i < files.size (); i++)
00611 {
00612 cmt_string& file = files[i];
00613
00614 if (test_directory (file))
00615 {
00616 if (!remove_directory (file)) return (false);
00617 }
00618 else
00619 {
00620 if (!remove_file (file)) return (false);
00621 }
00622 }
00623
00624 int status = ::rmdir (name);
00625 if (status != 0)
00626 {
00627 cerr << "#CMT> Cannot remove directory " << name << " errno=" << errno << endl;
00628 return (false);
00629 }
00630
00631 return (true);
00632 }
|
|
| ? |
Definition at line 590 of file cmt_system.cxx. Referenced by CmtInstallAreaMgr::config(), Cmt::do_config(), remove_directory(), and CmtLock::unlock(). 00591 {
00592 if (::unlink (name) != 0)
00593 {
00594 cerr << "#CMT> Cannot remove file " << name << endl;
00595 return (false);
00596 }
00597
00598 return (true);
00599 }
|
|
| ? |
Definition at line 908 of file cmt_system.cxx. References scan_dir(). 00909 {
00910 static cmt_string_vector result;
00911
00912 scan_dir (dir_name, result);
00913
00914 return (result);
00915 }
|
|
||||||||||||||||
| ? |
Definition at line 816 of file cmt_system.cxx. References cmt_vector< cmt_string >::add(), cmt_string::c_str(), cmt_vector< cmt_string >::clear(), dirname(), file_separator(), cmt_regexp::match(), name(), and test_directory(). 00819 {
00820 static cmt_string dir_prefix;
00821
00822 dir_prefix = dir_name;
00823 if (dir_name == "") dir_prefix = ".";
00824
00825 if (!test_directory (dir_prefix))
00826 {
00827 dirname (dir_prefix, dir_prefix);
00828 }
00829
00830 list.clear ();
00831
00832 #ifdef WIN32
00833
00834 long dir;
00835 struct _finddata_t entry;
00836
00837 static cmt_string search;
00838
00839 search = dir_prefix;
00840 search += file_separator ();
00841 search += "*";
00842
00843 dir = _findfirst (search.c_str (), &entry);
00844 if (dir > 0)
00845 {
00846 for (;;)
00847 {
00848 if ((entry.name[0] != '.') &&
00849 (strcmp ((char*) entry.name, ".") != 0) &&
00850 (strcmp ((char*) entry.name, "..") != 0) &&
00851 (strncmp ((char*) entry.name, ".nfs", 4) != 0))
00852 {
00853 const char* name = entry.name;
00854
00855 if (expression.match (name))
00856 {
00857 cmt_string& name_entry = list.add ();
00858
00859 name_entry = dir_prefix;
00860 name_entry += file_separator ();
00861 name_entry += name;
00862 }
00863 }
00864
00865 int status = _findnext (dir, &entry);
00866 if (status != 0)
00867 {
00868 break;
00869 }
00870 }
00871 _findclose (dir);
00872 }
00873 #else
00874
00875 //cout << "scan_dir> dir=" << dir_name << endl;
00876
00877 DIR* dir = opendir (dir_prefix.c_str ());
00878
00879 struct dirent* entry;
00880
00881 if (dir != 0)
00882 {
00883 while ((entry = readdir (dir)) != 0)
00884 {
00885 //if (entry->d_name[0] == '.') continue;
00886 if (!strcmp ((char*) entry->d_name, ".")) continue;
00887 if (!strcmp ((char*) entry->d_name, "..")) continue;
00888 if (!strncmp ((char*) entry->d_name, ".nfs", 4)) continue;
00889
00890 const char* name = entry->d_name;
00891
00892 if (!expression.match (name)) continue;
00893
00894 cmt_string& name_entry = list.add ();
00895
00896 name_entry = dir_prefix;
00897 name_entry += file_separator ();
00898 name_entry += name;
00899 }
00900
00901 closedir (dir);
00902 }
00903 #endif
00904
00905 }
|
|
||||||||||||
| ? |
Definition at line 701 of file cmt_system.cxx. References cmt_vector< cmt_string >::add(), basename(), cmt_string::c_str(), cmt_vector< cmt_string >::clear(), dirname(), cmt_string::erase(), file_separator(), cmt_string::find(), name(), cmt_string::npos, cmt_string::size(), and test_directory(). Referenced by CmtInstallAreaMgr::config(), Cmt::do_config(), Cmt::do_remove(), CvsImplementation::find_matching_version(), CmtGenerator::get_all_files(), is_package_directory(), Use::reach_package(), remove_directory(), UseAnalyzer::run(), scan_dir(), PathScanner::scan_package(), and PathScanner::scan_path(). 00703 {
00704 static cmt_string dir_prefix;
00705 static cmt_string name_prefix;
00706
00707 dir_prefix = dir_name;
00708 if (dir_name == "") dir_prefix = ".";
00709
00710 if (!test_directory (dir_prefix))
00711 {
00712 dirname (dir_prefix, dir_prefix);
00713 basename (dir_name, name_prefix);
00714 }
00715 else
00716 {
00717 }
00718
00719 bool need_filter = false;
00720
00721 int wild_card;
00722
00723 wild_card = name_prefix.find ('*');
00724 if (wild_card != cmt_string::npos)
00725 {
00726 name_prefix.erase (wild_card);
00727 }
00728
00729 if (name_prefix.size () > 0)
00730 {
00731 need_filter = true;
00732 }
00733
00734 list.clear ();
00735
00736 #ifdef WIN32
00737
00738 long dir;
00739 struct _finddata_t entry;
00740
00741 static cmt_string search;
00742
00743 search = dir_prefix;
00744 search += file_separator ();
00745 search += "*";
00746
00747 dir = _findfirst (search.c_str (), &entry);
00748 if (dir > 0)
00749 {
00750 for (;;)
00751 {
00752 if ((strcmp ((char*) entry.name, ".") != 0) &&
00753 (strcmp ((char*) entry.name, "..") != 0) &&
00754 (strncmp ((char*) entry.name, ".nfs", 4) != 0))
00755 {
00756 const char* name = entry.name;
00757
00758 if (!need_filter ||
00759 (strncmp (name, name_prefix.c_str (), name_prefix.size ()) == 0))
00760 {
00761 cmt_string& name_entry = list.add ();
00762
00763 name_entry = dir_prefix;
00764 name_entry += file_separator ();
00765 name_entry += name;
00766 }
00767 }
00768
00769 int status = _findnext (dir, &entry);
00770 if (status != 0)
00771 {
00772 break;
00773 }
00774 }
00775
00776 _findclose (dir);
00777 }
00778 #else
00779
00780 //cout << "scan_dir> dir=" << dir_name << endl;
00781
00782 DIR* dir = opendir (dir_prefix.c_str ());
00783
00784 struct dirent* entry;
00785
00786 if (dir != 0)
00787 {
00788 while ((entry = readdir (dir)) != 0)
00789 {
00790 //if (entry->d_name[0] == '.') continue;
00791 if (!strcmp ((char*) entry->d_name, ".")) continue;
00792 if (!strcmp ((char*) entry->d_name, "..")) continue;
00793 if (!strncmp ((char*) entry->d_name, ".nfs", 4)) continue;
00794
00795 const char* name = entry->d_name;
00796
00797 if (need_filter &&
00798 (strncmp (name, name_prefix.c_str (), name_prefix.size ()) != 0)) continue;
00799
00800 //cout << "scan_dir> name=" << name << endl;
00801
00802 cmt_string& name_entry = list.add ();
00803
00804 name_entry = dir_prefix;
00805 name_entry += file_separator ();
00806 name_entry += name;
00807 }
00808
00809 closedir (dir);
00810 }
00811 #endif
00812
00813 }
|
|
||||||||||||||||
| ? |
Definition at line 1716 of file cmt_system.cxx. References cmt_vector< cmt_string >::add(), cmt_string::c_str(), cmt_vector< cmt_string >::clear(), and cmt_string::size(). Referenced by Use::action(), Fragment::action(), add_cmt_paths_from_text(), PathBuilder::build(), Use::build_library_links(), CmtLock::check(), PathBuilder::clean(), CmtInstallAreaMgr::config(), DependencyAnalyzer::DependencyAnalyzer(), Cmt::do_broadcast(), SyntaxParser::do_parse_line(), Cmt::do_remove_library_links(), CmtModel::expand(), DependencyAnalyzer::filter(), TriggerAnalyzer::filter(), SequenceRunner::filter(), ProjectPatcher::filter(), ProjectReader::filter(), CmtMountFilterParser::filter(), Prototyper::filter(), Packager::filter(), WinDefAwk::filter(), RecursivePass2::filter(), RecursivePass1::filter(), Cut::filter(), CvsImplementation::filter_list(), get_best_form(), get_cmt_paths(), CvsImplementation::match_version_request(), mkdir(), Constituent::parse(), Cmt::parse_arguments(), Cmt::parser(), Cmt::print(), CvsImplementation::really_checkout_package(), Cmt::restore_all_tags(), ClientCollector::run(), DepsBuilder::run(), Cmt::set_standard_macros(), StandardMacroBuilder::StandardMacroBuilder(), CmtModel::strict_expand(), and CvsImplementation::tags(). 01719 {
01720 static char* buffer = 0;
01721 static int allocated = 0;
01722
01723 bool finished = false;
01724
01725 strings.clear ();
01726
01727 if (text.size () == 0) return;
01728
01729 /*
01730 We are going to work in a copy of the text, since
01731 \0 will be inserted right after each found word.
01732
01733 Then the vector of strings is iteratively filled by each found word.
01734 */
01735
01736 if (buffer == 0)
01737 {
01738 allocated = text.size ();
01739 buffer = (char*) malloc (allocated + 1);
01740 }
01741 else
01742 {
01743 if (text.size () > allocated)
01744 {
01745 allocated = text.size ();
01746 buffer = (char*) realloc (buffer, allocated + 1);
01747 }
01748 }
01749
01750 strcpy (buffer, text.c_str ());
01751
01752 /*
01753 Algorithm :
01754
01755 We look for words separated by
|
|
| ? |
Implementation of the "test -d" equivalent. Definition at line 303 of file cmt_system.cxx. References cmt_string::c_str(). Referenced by add_cmt_path(), DocumentGenerator::analyze_file(), LibraryGenerator::analyze_file(), DocumentGenerator::build(), CvsImplementation::checkout_package(), Cmt::configure_home(), Cmt::configure_user_context(), Project::create(), Cmt::do_config(), Cmt::do_create(), Cmt::do_remove(), Project::find_in_cmt_paths(), CvsImplementation::find_matching_version(), Cmt::load(), mkdir(), Cmt::parse_arguments(), CvsImplementation::really_checkout_package(), remove_directory(), VSNETGenerator::reset(), MSDEVGenerator::reset(), CmtGenerator::reset(), scan_dir(), PathScanner::scan_package(), PathScanner::scan_path(), and CvsImplementation::show_cvs_infos(). 00304 {
00305 struct stat file_stat;
00306 int status;
00307
00308 status = stat (name.c_str (), &file_stat);
00309
00310 if (status == 0)
00311 {
00312 if ((file_stat.st_mode & S_IFDIR) == 0)
00313 {
00314 return (false);
00315 }
00316 else
00317 {
00318 return (true);
00319 }
00320 }
00321 else
00322 {
00323 return (false);
00324 }
00325 }
|
|
| ? |
Implementation of the "test -f" equivalent. Definition at line 328 of file cmt_system.cxx. References cmt_string::c_str(). Referenced by add_cmt_paths(), DocumentGenerator::analyze_file(), LibraryGenerator::analyze_file(), ConstituentsMakefileGenerator::build(), DefaultMakefileGenerator::build(), DocumentGenerator::build(), build_deps(), CvsImplementation::checkout_package(), CmtGenerator::commit(), CmtInstallAreaMgr::config(), Cmt::configure_current_package(), Project::create(), ProjectFactory::create_project(), CvsImplementation::do_checkout(), Cmt::do_config(), Cmt::do_create(), Cmt::do_filter(), SyntaxParser::do_parse_requirements(), is_package_directory(), LibraryGenerator::java_file_action(), Fragment::locate(), LibraryGenerator::prepare_proto_file(), Cmt::reach_current_package(), Use::reach_package(), ClientCollector::run(), PackageSelector::run(), FAwk::run(), PathScanner::scan_package(), PathScanner::scan_path(), and Cmt::set_standard_macros(). 00329 {
00330 struct stat file_stat;
00331 int status;
00332
00333 status = stat (name.c_str (), &file_stat);
00334
00335 if (status == 0)
00336 {
00337 if ((file_stat.st_mode & S_IFDIR) == 0)
00338 {
00339 return (true);
00340 }
00341 else
00342 {
00343 return (false);
00344 }
00345 }
00346 else
00347 {
00348 return (false);
00349 }
00350 }
|
|
| ? |
Definition at line 1179 of file cmt_system.cxx. Referenced by ApplyPattern::action(), Pattern::action(), ApplyPattern::apply(), Pattern::apply(), Cmt::configure_home(), Cmt::configure_tags(), Cmt::configure_user_context(), Pattern::expand(), CmtModel::expand(), StandardMacroBuilder::fill_for_tag(), cmt_or_node::match(), cmt_and_node::match(), Cmt::parse_arguments(), Cmt::restore_all_tags(), Awk::run(), cmt_regexp::set(), and Cmt::set_standard_macros(). 01180 {
01181 const char* env = ::getenv (name);
01182 if (env == 0) return (false);
01183 return (true);
01184 }
|
|
| ? |
Definition at line 2023 of file cmt_system.cxx. References getenv(). Referenced by ReadmeGenerator::build(), DocumentGenerator::build(), LibraryGenerator::build(), CmtLock::check(), and CmtLock::lock(). 02024 {
02025 #ifdef _WIN32
02026 cmt_string result = getenv ("USERNAME");
02027 #else
02028 cmt_string result = getenv ("USER");
02029 #endif
02030
02031 return (result);
02032 }
|