예제 #1
0
lemur::parse::KeyfileDocMgr::KeyfileDocMgr(string name, string mode, string source) {
  myDoc = NULL;
  numdocs = 0;
  _readOnly = false;
  ignoreDoc = false;
  IDname = name;
  IDnameext = IDname+BT_TOC;
  if (!loadTOC()) {
    // brand new. create
    pm = mode;
    setParser(lemur::api::TextHandlerManager::createParser(mode));
    string val = IDname + BT_LOOKUP;
    doclookup.create(val);
    val = IDname + BT_POSITIONS;
    poslookup.create(val);
  }
  // how many have been parsed already.
  numOldSources = sources.size();
  // add the new files.
  ifstream files(source.c_str());
  string file;
  if (files.is_open()) {
    while (getline(files, file)) {
      sources.push_back(file);
    }
    files.close();
  } else {
    cerr << "Could not open file of sources: " << source << endl;
  }
}
예제 #2
0
bool Win32AudioCDManager::openCD(const Common::String &drive) {
	// Just some bounds checking
	if (drive.empty() || drive.size() > 3)
		return false;

	if (!Common::isAlpha(drive[0]) || drive[1] != ':')
		return false;

	if (drive[2] != 0 && drive[2] != '\\')
		return false;

	DriveList drives;
	if (!tryAddDrive(toupper(drive[0]), drives))
		return false;

	// Construct the drive path and try to open it
	Common::String drivePath = Common::String::format("\\\\.\\%c:", drives[0]);
	_driveHandle = CreateFileA(drivePath.c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
	if (_driveHandle == INVALID_HANDLE_VALUE) {
		warning("Failed to open drive %c:\\, error %d", drives[0], (int)GetLastError());
		return false;
	}

	if (!loadTOC()) {
		close();
		return false;
	}

	return true;
}
예제 #3
0
lemur::parse::ElemDocMgr::ElemDocMgr(string name, string mode, string source) {
  _readOnly = false;
  IDname = name;
  IDnameext = IDname+ELEM_TOC;
  if (! loadTOC()) {    
    pm = mode;
    setParser(lemur::api::TextHandlerManager::createParser(mode));
    string val = IDname + BT_LOOKUP;
    doclookup.create( val.c_str() );
    val = IDname + BT_POSITIONS;
    poslookup.create( val.c_str() );
    val = IDname + ELEM_ELS;
    elements.create( val.c_str());
  }
  // how many have been parsed already.
  numOldSources = sources.size();
  ifstream files(source.c_str());
  string file;
  if (files.is_open()) {
      // filenames may have spaces.
    while (getline(files, file)) {
        sources.push_back(file);
    }
    files.close();
  } else {
    cerr << "Could not open file of sources: " << source << endl;
  }
}
예제 #4
0
lemur::parse::KeyfileDocMgr::KeyfileDocMgr(const string &name, bool readOnly) {
  myDoc = NULL;
  _readOnly = readOnly;
  numdocs = 0;
  ignoreDoc = false;
  IDnameext = name;
  // strip extension
  IDname = IDnameext.substr(0, IDnameext.length() - 4);

  if (!loadTOC()) {
    // brand new.
    string val = IDname + BT_LOOKUP;
    doclookup.create(val);

    val = IDname + BT_POSITIONS;
    poslookup.create(val);
    pm = "trec"; /// bleah fix me
    setParser(lemur::api::TextHandlerManager::createParser());
  }
  // how many have been parsed already.
  numOldSources = sources.size();
}
예제 #5
0
lemur::parse::ElemDocMgr::ElemDocMgr(const string &name, bool readOnly) {
  _readOnly = readOnly;
  IDnameext = name;
  // strip extension
  IDname = IDnameext.substr(0, IDnameext.length() - ELEM_TOC_LEN);

  if (!loadTOC()) {
    // brand new.
    string val = IDname + BT_LOOKUP;
    doclookup.create( val.c_str() );

    val = IDname + BT_POSITIONS;
    poslookup.create( val.c_str() );
    pm = "trec"; /// bleah fix me
    setParser(lemur::api::TextHandlerManager::createParser());

    val = IDname + ELEM_ELS;
    elements.create( val.c_str());    
  }
  // how many have been parsed already.
  numOldSources = sources.size();
}
예제 #6
0
bool Win32AudioCDManager::openCD(int drive) {
	// Fetch the drive list
	DriveList drives = detectDrives();
	if (drive >= (int)drives.size())
		return false;

	debug(1, "Opening CD drive %c:\\", drives[drive]);

	// Construct the drive path and try to open it
	Common::String drivePath = Common::String::format("\\\\.\\%c:", drives[drive]);
	_driveHandle = CreateFileA(drivePath.c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
	if (_driveHandle == INVALID_HANDLE_VALUE) {
		warning("Failed to open drive %c:\\, error %d", drives[drive], (int)GetLastError());
		return false;
	}

	if (!loadTOC()) {
		close();
		return false;
	}

	return true;
}