? |
Definition at line 609 of file cmt_awk.cxx.
References _level, CmtSystem::basename(), CmtSystem::dirname(), cmt_string::erase(), CmtSystem::file_separator(), cmt_string::find(), CmtSystem::is_version_directory(), cmt_string::npos, cmt_string::read(), cmt_string::replace_all(), PathScanner::actor::run(), CmtSystem::scan_dir(), scan_path(), cmt_vector< cmt_string >::size(), CmtSystem::test_directory(), and CmtSystem::test_file().
00610 {
00611 if (level > 10)
00612 {
00613 cout << "#PathScanner::scan_path> too deep search path=" << path << endl;
00614 }
00615
00616
00617
00618
00619
00620 if (!CmtSystem::test_directory (path)) return;
00621
00622 CmtSystem::cmt_string_vector list;
00623 CmtSystem::cmt_string_vector entrylist;
00624
00625 CmtSystem::scan_dir (path, list);
00626
00627 if (list.size () == 0) return;
00628
00629 _level++;
00630
00631
00632 bool has_package = false;
00633
00634 cmt_string name;
00635 cmt_string version;
00636 cmt_string where;
00637
00638 int i;
00639
00640 for (i = 0; i < list.size (); i++)
00641 {
00642 const cmt_string& here = list[i];
00643
00644 if (!CmtSystem::test_directory (here)) continue;
00645
00646 name = "";
00647 version = "";
00648
00649 cmt_string entry;
00650 CmtSystem::basename (here, entry);
00651 CmtSystem::dirname (path, where);
00652
00653
00654
00655 if ((level == 0) && (entry == "InstallArea")) continue;
00656
00657 cmt_string req;
00658
00659 req = here;
00660 req += CmtSystem::file_separator ();
00661 req += "mgr";
00662 req += CmtSystem::file_separator ();
00663 req += "requirements";
00664
00665 if (CmtSystem::test_file (req))
00666 {
00667
00668
00669
00670
00671 version = entry;
00672 CmtSystem::basename (path, name);
00673
00674
00675
00676 a.run (name, version, where);
00677 has_package = true;
00678
00679 continue;
00680 }
00681
00682 req = here;
00683 req += CmtSystem::file_separator ();
00684 req += "cmt";
00685 req += CmtSystem::file_separator ();
00686 req += "requirements";
00687
00688 if (CmtSystem::test_file (req))
00689 {
00690
00691
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701 cmt_string vreq;
00702 vreq = here;
00703 vreq += CmtSystem::file_separator ();
00704 vreq += "cmt";
00705 vreq += CmtSystem::file_separator ();
00706 vreq += "version.cmt";
00707
00708 if (CmtSystem::test_file (vreq))
00709 {
00710 version.read (vreq);
00711 int pos;
00712 pos = version.find ('\n');
00713 if (pos != cmt_string::npos) version.erase (pos);
00714 pos = version.find ('\r');
00715 if (pos != cmt_string::npos) version.erase (pos);
00716
00717
00718
00719 a.run (entry, version, path);
00720 has_package = true;
00721
00722 continue;
00723 }
00724
00725 cmt_string p;
00726
00727 p.read (req);
00728 int pos;
00729 pos = p.find ("package");
00730 if (pos != cmt_string::npos)
00731 {
00732 p.erase (0, pos+8);
00733 pos = p.find ('\n');
00734 if (pos != cmt_string::npos) p.erase (pos);
00735 pos = p.find ('\r');
00736 if (pos != cmt_string::npos) p.erase (pos);
00737 p.replace_all (" ", "");
00738 p.replace_all ("\t", "");
00739 if (p != "") name = p;
00740 }
00741
00742 if (name != "")
00743 {
00744
00745
00746 if (entry == name)
00747 {
00748
00749
00750
00751
00752 a.run (name, "v1", path);
00753 has_package = true;
00754
00755 continue;
00756 }
00757
00758 version = entry;
00759 CmtSystem::basename (path, entry);
00760
00761 if (entry == name)
00762 {
00763
00764
00765
00766
00767 a.run (name, version, where);
00768 has_package = true;
00769
00770 continue;
00771 }
00772
00773
00774
00775
00776 }
00777 else
00778 {
00779 version = entry;
00780 CmtSystem::basename (path, entry);
00781 }
00782
00783
00784
00785
00786
00787 if (CmtSystem::is_version_directory (version))
00788 {
00789
00790
00791 a.run (entry, version, where);
00792 has_package = true;
00793
00794 continue;
00795 }
00796
00797 name = version;
00798
00799 where += CmtSystem::file_separator ();
00800 where += entry;
00801
00802
00803
00804 a.run (name, "v1", where);
00805 has_package = true;
00806
00807 continue;
00808 }
00809
00810
00811
00812 scan_path (here, level + 1, a);
00813 }
00814
00815 if (has_package)
00816 {
00817
00818
00819
00820
00821 for (i = 0; i < entrylist.size (); i++)
00822 {
00823 const cmt_string& e = entrylist[i];
00824
00825 cmt_string p = path;
00826 p += CmtSystem::file_separator ();
00827 p += e;
00828
00829
00830
00831
00832
00833
00834 cout << "#PathScanner::scan_path> Restarting scan_path on p=" << p << endl;
00835
00836
00837 scan_path (p, 1, a);
00838 }
00839 }
00840
00841 _level--;
00842 }
|