예제 #1
0
char *File::getExtension ( ) {
	// keep backing up over m_filename till we hit a . or / or beginning
	char *f = getFilename();
	int32_t i = gbstrlen(m_filename);//m_filename.getLength();
	while ( --i > 0 ) {
		if ( f[i] == '.' ) break;
		if ( f[i] == '/' ) break;
	}
	if ( i == 0               ) return NULL;
	if ( f[i] == '/' ) return NULL;
	return &f[i+1];
}
예제 #2
0
//------------------------------------------------------------------------------
// Load a DTED cell into memory
//------------------------------------------------------------------------------
bool DtedFile::loadData()
{
    // Compute the filename (why can't we be given just one filename string!??)
    std::string temp_filename;
    const char* p = getPathname();
    if (p != nullptr)
    {
        temp_filename += p;
        temp_filename += '/';
    }
    p = getFilename();
    if (p != nullptr)
        temp_filename += p;

    // Open the terrain file.
    const char* filename = temp_filename.c_str();

    std::ifstream in;
    in.open(filename, std::ios::binary);
    if ( in.fail() )
    {
        if (isMessageEnabled(MSG_ERROR)) {
            std::cerr << "DtedFile::loadData() ERROR, could not open file: " << filename << std::endl;
        }
        return false;
    }

    // Read cell parameters from the DTED headers
    if (! readDtedHeaders(in))
    {
        clearData();
        in.close();
        if (isMessageEnabled(MSG_ERROR)) {
            std::cerr << "DtedFile::loadData() ERROR reading DTED headers in file: " << filename << std::endl;
        }
        return false;
    }

    // Read elevation data from the DTED file
    if (! readDtedData(in))
    {
        clearData();
        in.close();
        if (isMessageEnabled(MSG_ERROR)) {
            std::cerr << "DtedFile::loadData() ERROR reading data from file: " << filename << std::endl;
        }
        return false;
    }

    // Close the file
    in.close();
    return true;
}
예제 #3
0
std::string FileSystem::getFilenameWithoutExtension(const std::string &filePath)
{
    auto filename = getFilename(filePath);
    if (filename.empty())
        return "";

    auto dotPos = filename.find_last_of('.');
    if (dotPos == std::string::npos)
        return "";

    return std::string(filename.cbegin(), filename.cbegin() + dotPos);
}
예제 #4
0
void ProfileImportDlg::browseFile()
{
	QString filter("2D profile (*.txt)");

	//open file loading dialog
	QString filename = QFileDialog::getOpenFileName(0,"Select profile file",getFilename(),filter);

	if (filename.isEmpty())
		return;
	
	setDefaultFilename(filename);
}
예제 #5
0
void MTD_FLASHMEM MultipartFormDataProcessor::handle_DecodingHeaders(char c) {
  static char const EOH[4] = {0x0D, 0x0A, 0x0D, 0x0A};
  if (c == EOH[substate]) {
    ++substate;
    if (substate == 2) {
      // useful if this is not an EOH to separate headers
      headers->append(0x0D, 1);
    } else if (substate == 4) {
      // end of headers
      headers->append(0, 1); // add string terminating zero

      // look for "name" parameter
      CharChunksIterator keyBegin;
      extractParameter(FSTR(" name="), headers->getIterator(), &keyBegin, &nameBegin, &nameEnd);

      // look for "filename" parameter
      CharChunksIterator filenameBegin, filenameEnd;

      if (extractParameter(FSTR(" filename="), headers->getIterator(), &keyBegin, &filenameBegin, &filenameEnd)) {
        //// this is a file
        // add "filename" to form fields
        filenameBegin = getFilename(filenameBegin,
                                    filenameEnd); // some browsers send a full path instead of a simple file name (IE)
        formfields->add(keyBegin + 1, keyBegin + 9, filenameBegin, filenameEnd);

        // extract Content-Type parameter
        CharChunksIterator contentTypeBegin, contentTypeEnd;
        if (extractParameter(FSTR("Content-Type:"), filenameEnd, &keyBegin, &contentTypeBegin, &contentTypeEnd)) {
          // add "Content-Type" to form fields
          formfields->add(keyBegin, keyBegin + 12, contentTypeBegin, contentTypeEnd);

          // create file
          file.create(APtr<char>(t_strdup(filenameBegin, filenameEnd)).get(),
                      APtr<char>(t_strdup(contentTypeBegin, contentTypeEnd)).get());

          state = GettingFile;
        } else {
          // missing content-type, cannot get as file!
          state = GettingValue;
        }
      } else {
        //// this is a normal field
        valueStorage = chunksFactory.add();
        state = GettingValue;
      }
      substate = 0;
    }
  } else {
    // add to headers buffer
    headers->append(c, HEADERS_CHUNK_SIZE);
    substate = 0;
  }
}
        bool FatDirectoryIterator::moveTo(const char *filename) {

            while(next()) {

                if(!strcasecmp(getFilename(),filename))
                    return true;
            }

            // not found

            return errorProvider.set(ErrorProvider::ERROR_PROVIDER_DIRECTORY_ITERATOR,E_ENTRY_NOT_FOUND);
        }
예제 #7
0
파일: P.cpp 프로젝트: lwhay/ICDMS
void P::factor() {
	returnAST = RefBasicAST(ANTLR_USE_NAMESPACE(antlr)nullAST);
	ANTLR_USE_NAMESPACE(antlr)ASTPair currentAST;
	RefBasicAST factor_AST = RefBasicAST(ANTLR_USE_NAMESPACE(antlr)nullAST);
	
	try {      // for error handling
		factor2();
		astFactory->addASTChild(currentAST, ANTLR_USE_NAMESPACE(antlr)RefAST(returnAST));
		{ // ( ... )*
		for (;;) {
			if ((LA(1) == MOD || LA(1) == EXP)) {
				{
				switch ( LA(1)) {
				case EXP:
				{
					RefBinaryCompArithOpAST tmp11_AST = RefBinaryCompArithOpAST(RefBasicAST(ANTLR_USE_NAMESPACE(antlr)nullAST));
					tmp11_AST = astFactory->create(LT(1));
					astFactory->makeASTRoot(currentAST, ANTLR_USE_NAMESPACE(antlr)RefAST(tmp11_AST));
					match(EXP);
					break;
				}
				case MOD:
				{
					RefBinaryCompArithOpAST tmp12_AST = RefBinaryCompArithOpAST(RefBasicAST(ANTLR_USE_NAMESPACE(antlr)nullAST));
					tmp12_AST = astFactory->create(LT(1));
					astFactory->makeASTRoot(currentAST, ANTLR_USE_NAMESPACE(antlr)RefAST(tmp12_AST));
					match(MOD);
					break;
				}
				default:
				{
					throw ANTLR_USE_NAMESPACE(antlr)NoViableAltException(LT(1), getFilename());
				}
				}
				}
				factor2();
				astFactory->addASTChild(currentAST, ANTLR_USE_NAMESPACE(antlr)RefAST(returnAST));
			}
			else {
				goto _loop14;
			}
			
		}
		_loop14:;
		} // ( ... )*
		factor_AST = RefBasicAST(currentAST.root);
	}
	catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) {
		reportError(ex);
		recover(ex,_tokenSet_3);
	}
	returnAST = factor_AST;
}
예제 #8
0
파일: P.cpp 프로젝트: lwhay/ICDMS
void P::arith_exp() {
	returnAST = RefBasicAST(ANTLR_USE_NAMESPACE(antlr)nullAST);
	ANTLR_USE_NAMESPACE(antlr)ASTPair currentAST;
	RefBasicAST arith_exp_AST = RefBasicAST(ANTLR_USE_NAMESPACE(antlr)nullAST);
	
	try {      // for error handling
		term();
		astFactory->addASTChild(currentAST, ANTLR_USE_NAMESPACE(antlr)RefAST(returnAST));
		{ // ( ... )*
		for (;;) {
			if ((LA(1) == PLUS || LA(1) == MINUS)) {
				{
				switch ( LA(1)) {
				case PLUS:
				{
					RefBinaryCompArithOpAST tmp7_AST = RefBinaryCompArithOpAST(RefBasicAST(ANTLR_USE_NAMESPACE(antlr)nullAST));
					tmp7_AST = astFactory->create(LT(1));
					astFactory->makeASTRoot(currentAST, ANTLR_USE_NAMESPACE(antlr)RefAST(tmp7_AST));
					match(PLUS);
					break;
				}
				case MINUS:
				{
					RefBinaryCompArithOpAST tmp8_AST = RefBinaryCompArithOpAST(RefBasicAST(ANTLR_USE_NAMESPACE(antlr)nullAST));
					tmp8_AST = astFactory->create(LT(1));
					astFactory->makeASTRoot(currentAST, ANTLR_USE_NAMESPACE(antlr)RefAST(tmp8_AST));
					match(MINUS);
					break;
				}
				default:
				{
					throw ANTLR_USE_NAMESPACE(antlr)NoViableAltException(LT(1), getFilename());
				}
				}
				}
				term();
				astFactory->addASTChild(currentAST, ANTLR_USE_NAMESPACE(antlr)RefAST(returnAST));
			}
			else {
				goto _loop6;
			}
			
		}
		_loop6:;
		} // ( ... )*
		arith_exp_AST = RefBasicAST(currentAST.root);
	}
	catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) {
		reportError(ex);
		recover(ex,_tokenSet_1);
	}
	returnAST = arith_exp_AST;
}
예제 #9
0
파일: savegame.cpp 프로젝트: peres/scummvm
void SaveLoad::flushStream(GameId id) {
	Common::OutSaveFile *save = openForSaving(id);
	if (!save)
		error("SaveLoad::flushStream: cannot open savegame (%s)!", getFilename(id).c_str());

	if (!_savegame)
		error("SaveLoad::flushStream: savegame stream is invalid");

	save->write(_savegame->getData(), (uint32)_savegame->size());

	delete save;
}
예제 #10
0
	void confirmUpload(
		const std::string& confirmation_url,
		boost::intrusive_ptr<LLNewAgentInventoryVariablePriceResponder> responder)
	{
		if ( getFilename().empty() )
		{
			// we have no filename, use virtual file ID instead
			LLHTTPClient::postFile(
				confirmation_url,
				getVFileID(),
				getAssetType(),
				responder);
		}
		else
		{
			LLHTTPClient::postFile(
				confirmation_url,
				getFilename(),
				responder);
		}
	}
예제 #11
0
// . returns -1 on error
// . returns  0 if does not exist
// . returns  1 if it exists
int32_t File::doesExist ( ) {
	// preserve g_errno
	int old_errno = g_errno;
	// allow the substitution of another filename
        struct stat stats;
	// return true if it exists
        if ( stat ( getFilename() , &stats ) == 0 ) return 1;
	// copy errno to g_errno
	g_errno = errno;
        // return 0 if it just does not exist and reset g_errno
        if ( g_errno == ENOENT ) { g_errno = old_errno; return 0; }
        // resource temporarily unavailable (for newer libc)
        if ( g_errno == EAGAIN ) { g_errno = old_errno; return 0; }
        // log & return -1 on any other error
	if ( ! g_errno ) {
		log("process: you tried to overload __errno_location() "
		    "but were unsuccessful. you need to be using pthreads.");
		char *xx=NULL;*xx=0; 
	}
        log("disk: error stat3(%s): %s", getFilename() , strerror(g_errno));
        return -1;
}
예제 #12
0
void EditOptions::saveScreenSize(int width, int height)
    {
    if(getFilename().length() > 0)
        {
        setScreenCoord("ScreenWidth", width);
        setScreenCoord("ScreenHeight", height);
        OovStatus status = writeFile();
        if(status.needReport())
            {
            status.report(ET_Error, "Unable to write edit options");
            }
        }
    }
예제 #13
0
void yyerror(const char* message, ...)
{
    va_list ap;

    va_start(ap, message);
    fprintf(stderr, "%s %d.%d-%d.%d: ",
            getFilename().c_str(),
            yylloc.first_line, yylloc.first_column,
            yylloc.last_line, yylloc.last_column);
    vfprintf(stderr, message, ap);
    fprintf(stderr, "\n");
    va_end(ap);
}
예제 #14
0
void
Bucket::apply(Database& db) const
{
    if (getFilename().empty())
    {
        return;
    }
    BucketEntry entry;
    XDRInputFileStream in;
    in.open(getFilename());
    size_t i = 0;
    db.getSession().begin();
    while (in && in.readOne(entry))
    {
        LedgerHeader
            lh; // buckets, by definition are independent from the header
        LedgerDelta delta(lh, db, false);
        if ((i++ & 0xfff) == 0xfff)
        {
            db.clearPreparedStatementCache();
            db.getSession().commit();
            CLOG(INFO, "Bucket") << "Bucket-apply: committed " << i
                                 << " entries";
            db.getSession().begin();
        }
        if (entry.type() == LIVEENTRY)
        {
            EntryFrame::pointer ep = EntryFrame::FromXDR(entry.liveEntry());
            ep->storeAddOrChange(delta, db);
        }
        else
        {
            EntryFrame::storeDelete(delta, db, entry.deadEntry());
        }
        // No-op, just to avoid needless rollback.
        delta.commit();
    }
    db.getSession().commit();
}
예제 #15
0
void Repository::Git::GitFile::printContent()
{

	// vypise informacie o subore
	qDebug() << "filename: " << getFilename();
	qDebug() << "filepath: " << getFilepath();
	qDebug() << "type: " << getTypeAsString();

	// pre kazdy diff blok vypis informacie o danom bloku
	foreach ( GitFileDiffBlock* block, getGitFileDiffBlocks() ) {
		block->printInfo();
	}
}
예제 #16
0
QString Classifier::getCategory(const QString &filename)
{
    QStringList categories = getCategories();
    for(QStringList::ConstIterator it = categories.constBegin(); it != categories.constEnd(); ++it)
    {
        if(getFilename(*it) == filename)
        {
            return *it;
        }
    }

    return QString::null;
}
예제 #17
0
void StartupDlg::actionChanged( int action, bool browse)
{
  DBGOUT("action" << action);
  if(action == 2) { // create new selected
    passPhraseStack->setCurrentIndex(1);
    newPassPhraseBox->setFocus();
  }
  else {
    assert(m_myps != NULL);
    if(action == 1) { // browse selected
      if(browse) {
	// display open safe dialog
	QString filename, filter;
	if(m_myps->browseForSafe(filename, filter, false) == false) { // canceled
	  return;
	}
	// update the file name
	setFilename(filename);
	setFilter(filter);
      }
      else {
	setFilename(getFilename());
      }
    }
    else { // open default selected
      if(m_myps->getDefaultSafe().isEmpty() != true) {
	setFilename(m_myps->getDefaultSafe());
	setFilter(QString::null);
      }
      else {
	actionChanged(1); // set the action to browse
	m_myps->setDefaultSafe(getFilename());
      }
    }
    passPhraseStack->setCurrentIndex(0);
    passPhraseBox->setFocus();
  }
}
예제 #18
0
static void
loadCumulativeStats( const tr_session * session,
                     tr_session_stats * setme )
{
    tr_benc top;
	char * path;
    char * filename;
    bool loaded = false;

    path = filename = getFilename( session );
#ifdef WIN32
	path = ConvertUtf8ToTChar(filename);
#endif
    loaded = !tr_bencLoadFile( &top, TR_FMT_JSON, path );
#ifdef WIN32
	tr_free(path);
#endif
    tr_free( filename );

    if( !loaded )
    {
        path = filename = getOldFilename( session );
#ifdef WIN32
		path = ConvertUtf8ToTChar(filename);
#endif
        loaded = !tr_bencLoadFile( &top, TR_FMT_BENC, path );
#ifdef WIN32
		tr_free(path);
#endif
        tr_free( filename );
    }

    if( loaded )
    {
        int64_t i;

        if( tr_bencDictFindInt( &top, "downloaded-bytes", &i ) )
            setme->downloadedBytes = (uint64_t) i;
        if( tr_bencDictFindInt( &top, "files-added", &i ) )
            setme->filesAdded = (uint64_t) i;
        if( tr_bencDictFindInt( &top, "seconds-active", &i ) )
            setme->secondsActive = (uint64_t) i;
        if( tr_bencDictFindInt( &top, "session-count", &i ) )
            setme->sessionCount = (uint64_t) i;
        if( tr_bencDictFindInt( &top, "uploaded-bytes", &i ) )
            setme->uploadedBytes = (uint64_t) i;

        tr_bencFree( &top );
    }
}
void dumpSingleJetFractionsLost()
{
	// Let the user know...
	cout << "Getting files like " << (char *)getFilename(1) << endl;
	cout << endl;

	// The ctau we are going to look at.
	vector<int> ctaus;
	for (int i = 0; i < 12; i++) {
		ctaus.push_back(1 + i * 5);
	}

	// And the masses we are going to look at.
	vector<pair<int, int> > masses;
	masses.push_back(pair<int, int>(100, 10));
	masses.push_back(pair<int, int>(100, 25));
	masses.push_back(pair<int, int>(126, 10));
	masses.push_back(pair<int, int>(126, 25));
	masses.push_back(pair<int, int>(126, 40));
	masses.push_back(pair<int, int>(140, 10));
	masses.push_back(pair<int, int>(140, 20));
	masses.push_back(pair<int, int>(140, 40));
	masses.push_back(pair<int, int>(300, 50));
	masses.push_back(pair<int, int>(600, 50));
	masses.push_back(pair<int, int>(600, 150));
	masses.push_back(pair<int, int>(900, 50));
	masses.push_back(pair<int, int>(900, 150));

	// Now, load up the info for each mass
	vector<vector<double> > massResults;
	for (int iMass = 0; iMass < masses.size(); iMass++) {
		vector<double> eff = getEfficiencies(masses[iMass], ctaus);
		massResults.push_back(eff);
	}

	// Now dump it out in a nice "excel" format. First the header, then the body.
	cout << "ctau, ";
	for (int iMass = 0; iMass < masses.size(); iMass++) {
		cout << masses[iMass].first << "/" << masses[iMass].second << ", ";
	}
	cout << endl;

	for (int iCtau = 0; iCtau < ctaus.size(); iCtau++) {
		cout << ctaus[iCtau] << ", ";
		for (int iMass = 0; iMass < masses.size(); iMass++) {
			cout << massResults[iMass][iCtau] << ", ";
		}
		cout << endl;
	}
}
vector<double> getEfficiencies(const pair<int, int> &mPair, const vector<int> &ctaus)
{
	mboson = mPair.first;
	mvpion = mPair.second;

	vector<double> result;
	for (int i = 0; i < ctaus.size(); i++) {
		TFile *f = TFile::Open(getFilename(ctaus[i]));
		result.push_back(calcEff(f));
		f->Close();
	}

	return result;
}
예제 #21
0
파일: Save.cpp 프로젝트: scarsty/kys-cpp
void Save::loadR(int num)
{
    std::string filenamer = getFilename(num, 'r');
    std::string filename_idx = "../game/save/ranger.idx32";
    auto rgrp = GrpIdxFile::getIdxContent(filename_idx, filenamer, &offset_, &length_);
    memcpy((void*)this, rgrp.data() + offset_[0], length_[0]);
    File::readDataToVector(rgrp.data() + offset_[1], length_[1], roles_mem_, sizeof(RoleSave));
    File::readDataToVector(rgrp.data() + offset_[2], length_[2], items_mem_, sizeof(ItemSave));
    File::readDataToVector(rgrp.data() + offset_[3], length_[3], submap_infos_mem_, sizeof(SubMapInfoSave));
    File::readDataToVector(rgrp.data() + offset_[4], length_[4], magics_mem_, sizeof(MagicSave));
    File::readDataToVector(rgrp.data() + offset_[5], length_[5], shops_mem_, sizeof(ShopSave));

    updateAllPtrVector();
}
예제 #22
0
float getGPSVelocity(int counter) {
	vector<float> GPS; //read_data_for_frame
	String dataFile = getFilename("./data/oxts/data/", ".txt", counter);
	char temp[256];
	std::ifstream ifs (dataFile,std::ifstream::in);
	int size = 0;
	while (size < 9) {
		ifs.get(temp, 32, ' ');
		GPS.push_back((float)atof(temp));
		ifs.get(temp, 2);
		size++;
	}
	return length(GPS.at(6), GPS.at(7));
}
예제 #23
0
파일: mesh.cpp 프로젝트: donutmonger/Game
string Mesh::asJsonString() {
    // Returns the json formatted string of the mesh.
    // A single mesh is represented as (example):
    //      "mesh": "fence.dae",
    string json_string = "\"mesh\": ";
    json_string += "\"" + getFilename() + "\"";

    // If the filename is blank then this is not a 'saveable' mesh
    if (isBlank()) {
        json_string = "";
    }

    return json_string;
}
예제 #24
0
bool FileSystem::mkdev(const char* path, VFS_OPEN_MODES mode, DEVICE_TYPES type, pid_t pid)
{
	if(!path)
		return false;

	std::string fullpath;
	fullpath = path;
	
	std::string name = getFilename(fullpath, '/');
	fullpath.erase(fullpath.length() - name.length() - 1);
	
	//printf("mkdev: %s %s %d\n", fullpath.c_str(), name.c_str(), pid);
	return addNode(fullpath.c_str(), new FSDevice(name.c_str(), mode, type, pid));
}
예제 #25
0
std::string Camera::shoot()
{
    if (pslr_shutter(theHandle) != PSLR_OK)
    {
	DPRINT("Did not shoot.");
	return "";
    };
    std::string fn = getFilename();
    while (!saveBuffer(fn))
	usleep(10000);
    deleteBuffer();
    DPRINT("Shot.");
    return lastFilename;
}
예제 #26
0
// a wrapper for lseek
int32_t File::lseek ( int32_t offset , int whence ) {

	int32_t position = (int32_t) ::lseek ( m_fd , offset , whence );

	if ( position >= 0 ) return position;

	// copy errno to g_errno
	g_errno = errno;

	log("disk: lseek ( %s(%i) , %"INT32" , whence ): %s" , getFilename() , 
	      m_fd, offset , strerror ( g_errno ) );

	return -1;
}
예제 #27
0
void IOSCfgParser::ip_commands() {
	
	try {      // for error handling
		match(IP);
		{
		switch ( LA(1)) {
		case ACCESS_LIST:
		{
			ip_access_list_ext();
			break;
		}
		case ACCESS_GROUP:
		case ADDRESS:
		{
			interface_known_ip_commands();
			break;
		}
		case COMMUNITY_LIST:
		{
			community_list_command();
			break;
		}
		case ICMP:
		case TCP:
		case HOST:
		{
			ip_unused_command();
			break;
		}
		case WORD:
		{
			unknown_command();
			break;
		}
		default:
		{
			throw ANTLR_USE_NAMESPACE(antlr)NoViableAltException(LT(1), getFilename());
		}
		}
		}
	}
	catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) {
		if( inputState->guessing == 0 ) {
			reportError(ex);
			recover(ex,_tokenSet_2);
		} else {
			throw;
		}
	}
}
예제 #28
0
void IOSCfgParser::single_port_op() {
	
	try {      // for error handling
		{
		switch ( LA(1)) {
		case P_EQ:
		{
			match(P_EQ);
			break;
		}
		case P_GT:
		{
			match(P_GT);
			break;
		}
		case P_LT:
		{
			match(P_LT);
			break;
		}
		case P_NEQ:
		{
			match(P_NEQ);
			break;
		}
		default:
		{
			throw ANTLR_USE_NAMESPACE(antlr)NoViableAltException(LT(1), getFilename());
		}
		}
		}
		if ( inputState->guessing==0 ) {
#line 399 "iosacl.g"
			
			importer->tmp_port_op = LT(0)->getText();
			*dbg << LT(0)->getText() << " ";
			
#line 1980 "IOSCfgParser.cpp"
		}
		port_spec();
	}
	catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) {
		if( inputState->guessing == 0 ) {
			reportError(ex);
			recover(ex,_tokenSet_11);
		} else {
			throw;
		}
	}
}
예제 #29
0
bool File::rename ( char *newFilename ) {
	// close ourselves if we were open... why? historical reasons?
	close();
	// do the rename
	if ( ::rename ( getFilename() , newFilename ) != 0 ) 
		return false;
	// sync it to disk in case power goes out
	sync();
	//return log("file::rename: from %s to %s failed", 
	//m_filename , newFilename );
	// set to our new name
	set ( newFilename );
	return true;
}
예제 #30
0
// . BigFile calls this from inside a rename or unlink thread
// . it calls File::close() proper when out of the thread
// . PROBLEM #1: we close this fd, an open happens for the fd we just closed
//               and a pending read reads from the wrong fd. to fix this
//               i inc'd s_closeCountds[fd] right after the call to ::open()
//               BUT what if it is opened by a socket???!?!?!?! Then the
//               read should have got EBADF i guess...
// . otherwise, any read for this fd might fail with BADFD if it got closed 
//   before or during the read. in that case BigFile should retry 
// . PROBLEM #2: yeah, but if its a write, what then? if opened for writing,
//               NEVER allow the fd to be closed in closeLeastUsed()!!!
//               because if merge and dump going on at same time, and both get
//               their fds closed in closedLeastUsed(), then merge reopens his
//               file but with dumps fd, and a dump in mid thread using the
//               same old fd writes, he will write to the merge file!!!
void File::close1_r ( ) { 
	// assume no close
	m_closedIt = false;

	// debug. don't log in thread - might hurt us
	log(LOG_DEBUG,"disk: close1_r: Closing  fd %i for %s after "
	    "unlink/rename.",m_fd,getFilename());

	// problem. this could be a closed map file, m_vfd=-1.
	if ( m_fd < 0 ) {
		// -1 just means it was already closed, probably this is
		// from unlinking and RdbMap file which is closed after we
		// read it in at startup.
		log(LOG_DEBUG,"disk: close1_r: fd %i < 0",m_fd);
		return ;
	}
	// panic!
	if ( s_writing [ m_fd ] ) {
		log(LOG_LOGIC,"disk: close1_r: In write mode and closing.");
		return;
	}
	// if already being unlinked, skip
	if ( s_unlinking [ m_fd ] ) {
		log(LOG_LOGIC,"disk: close1_r: In unlink mode and closing.");
		return;
	}
	// this is < 0 if invalid
	//int fd = s_fds [ m_vfd ];

	if ( m_fd < 0 ) return ;
	// . do not allow closeLeastUsed to close this fd as well
	// . that can really mess us up:
	// . 1. we close this fd being unlinked/renamed
	// . 2. another file gets that fd
	// . 3. closeLeastUsed closes it again and sets our s_fds[m_vfd] to -1
	//      this leaving the other file with a seemingly valid fd that
	//      always gives EBADF errors cuz it was closed.
	s_unlinking [ m_fd ] = 1;
 again:
	if ( m_fd == 0 ) log("disk: closing1 fd of 0");
	if ( ::close(m_fd) == 0 ) { 
		m_closedIt = true; 
		// close2() needs to see m_fd so it can set flags...
		// so m_fd MUST be intact
		//m_fd = -1;
		return; 
	}
	log("disk: close(%i): %s.",m_fd,strerror(errno));
	if ( errno == EINTR ) goto again;
}