MCPcopy Create free account
hub / github.com/OpenDDS/OpenDDS / add_entry

Method add_entry

dds/DCPS/FileSystemStorage.cpp:693–740  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

691}
692
693ACE_TString Directory::add_entry()
694{
695 if (overflow_.empty()) {
696 overflow_[0] = 1;
697 return ACE_TEXT("");
698 }
699
700 typedef OPENDDS_MAP(unsigned int, unsigned int)::iterator iterator;
701 // find existing overflow bucket with capacity
702 bool found_gap(false);
703 unsigned int last_seen(0), unused_bucket(0);
704
705 for (iterator iter = overflow_.begin(), end = overflow_.end();
706 iter != end; ++iter) {
707 if (iter->second < OPENDDS_FILESYSTEMSTORAGE_MAX_FILES_PER_DIR) {
708 ++iter->second;
709
710 if (iter->first == 0) return ACE_TEXT("");
711
712 return overflow_dir_name(iter->first);
713 }
714
715 if (!found_gap && iter->first > last_seen + 1) {
716 found_gap = true;
717 unused_bucket = last_seen + 1;
718 }
719
720 last_seen = iter->first;
721 }
722
723 if (!found_gap) {
724 if (last_seen == FSS_MAX_OVERFLOW_DIR) {
725 throw std::runtime_error("Overflow serial # out of range.");
726 }
727
728 unused_bucket = last_seen + 1;
729 }
730
731 overflow_[unused_bucket] = 1;
732 ACE_TString dir_name = overflow_dir_name(unused_bucket);
733 CwdGuard cg(physical_dirname_);
734
735 if (dds_mkdir(dir_name.c_str()) == -1) {
736 throw std::runtime_error("Can't create overflow directory");
737 }
738
739 return dir_name;
740}
741
742void Directory::remove()
743{

Callers

nothing calls this directly

Calls 5

overflow_dir_nameFunction · 0.85
dds_mkdirFunction · 0.85
emptyMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected