示例#1
0
void Game::loadMaterials()
{
#ifdef NSPIRE
	FILE* exe = openFile(joinPath(lieroDataRoot, "materials.dat.tns"));
#else
	FILE* exe = openFile(joinPath(lieroDataRoot, "materials.dat"));
#endif

	for(int i = 0; i < 256; ++i)
	{
		materials[i].flags = 0;
	}
	
	unsigned char bits[32];
	
	for(int i = 0; i < 5; ++i)
	{
		fread(bits, 1, 32, exe);
		
		for(int j = 0; j < 256; ++j)
		{
			int bit = ((bits[j >> 3] >> (j & 7)) & 1);
			materials[j].flags |= bit << i;
		}
	}
	
	fread(bits, 1, 32, exe);
	
	for(int j = 0; j < 256; ++j)
	{
		int bit = ((bits[j >> 3] >> (j & 7)) & 1);
		materials[j].flags |= bit << 5;
	}
}
示例#2
0
string CCompiler::createCompilerCommand(const string& sourceFileName)
{
    stringstream exeCmd;
    if(getFileNameNoExtension(mCompilerName) == "tcc"
       || getFileNameNoExtension(mCompilerName) == "gcc"
       || getFileNameNoExtension(mCompilerName) == "cc")
    {
        // standard unix compiler options
        exeCmd<<joinPath(mCompilerLocation, mCompilerName);
        //Add compiler flags
        for(int i = 0; i < mCompilerFlags.size(); i++)
        {
            exeCmd<<" "<<mCompilerFlags[i];
        }
        exeCmd<<" \""<<sourceFileName<<"\" \""<<joinPath(mSupportCodeFolder, "rrSupport.c")<<"\"";


        exeCmd<<" -o \""<<mDLLFileName<<"\"";
#if defined(WIN32)
        exeCmd<<" -DBUILD_MODEL_DLL ";
#endif
        //Add include paths
        for(int i = 0; i < mIncludePaths.size(); i++)
        {
            exeCmd<<" -I\""<<mIncludePaths[i]<<"\" " ;
        }

        //Add library paths
        for(int i = 0; i < mLibraryPaths.size(); i++)
        {
            exeCmd<<" -L\""<<mLibraryPaths[i]<<"\" " ;
        }
    }
    return exeCmd.str();
}
示例#3
0
void ServerConnection::recvSendFile( const QString &filename, const QDateTime &mtime, const QByteArray &data, bool executable )
{
  qDebug() << "File " << fSourceDir << filename << " datasize " << data.size() << " date: " << mtime;

  QFile file( joinPath(fSourceDir,filename) );
  if( !file.open(QIODevice::WriteOnly) )
  {
    // maybe we are missing some directories
    QString filedir = joinPath( fSourceDir, filename ).section( '/', 0, -2 );
    QDir dir(filedir);
    bool result = true;
    if(!dir.exists())
    {
      result = dir.mkpath(filedir);
    }

    if( !result )
    {
      qWarning() << "Could not create path \"" << filedir << "\"";
    }
    else
    {
      file.open( QIODevice::WriteOnly );
    }
  }
  
  if( !file.isOpen() )
  {
    sendSendFileResult( filename, mtime, false );
    qWarning() << "Could not create file \"" << filename << "\"";
  }
  else
  {
    file.write( data );
    if(executable)
    {
      file.setPermissions(file.permissions()|QFile::ExeOwner|QFile::ExeGroup|QFile::ExeOther);
    }
    file.flush();
    
    // For some reason QFileInfo is lacking setLastModified()
    struct timeval times[2];
    times[0].tv_sec = times[1].tv_sec = mtime.toTime_t();
    times[0].tv_usec = times[1].tv_usec = 0;
    if( futimes(file.handle(), times) != 0 )
    {
      sendSendFileResult( filename, mtime, false );
      qWarning() << "Could not set times on file \"" << filename << "\"";
    }
    else
    {
      sendSendFileResult( filename, mtime, true );
    }
  }
}
示例#4
0
void Game::loadTextures()
{
#ifdef NSPIRE
	FILE* exe = openFile(joinPath(lieroDataRoot, "textures.dat.tns"));
#else
	FILE* exe = openFile(joinPath(lieroDataRoot, "textures.dat"));
#endif

	readMembers<ReadBool>(exe, textures, &Texture::nDrawBack);
	readMembers<Read8>(exe, textures, &Texture::mFrame);
	readMembers<Read8>(exe, textures, &Texture::sFrame);
	readMembers<Read8>(exe, textures, &Texture::rFrame);
}
示例#5
0
string changeFileExtensionTo(const string& _fName, const string& newExtension)
{
    //Be aware of the case
    //".\\fName"
    //where  the . is not part of the filename
    string path = getFilePath(_fName);
    string fName = getFileName(_fName);
    //First create the file name, remove current extension if it exists

    if(fName.find_last_of('.') != string::npos)
    {
        //Extension does exist. Cut it, and append new one
        fName =  fName.substr(0, fName.find_last_of('.'));
    }

    if(newExtension[0] == '.')
    {
        fName = fName + newExtension;
    }
    else if(newExtension.size() == 0)    //No extension
    {
        return fName;
    }
    else
    {
        fName = fName + "." + newExtension;
    }

    return joinPath(path, fName);
}
示例#6
0
void respond(int pSocket, string version, string path, string reqPath) {
	struct stat filestat;
	if(stat(path, filestat) == ERROR) {
		writeLine(pSocket, version + " 404 NOT FOUND");
		writeLine(pSocket, "Content-Type: text/html");
		string body = get404();
		string contentLength = to_string(body.length());
		writeLine(pSocket, "Content-Length: " + contentLength);
		writeLine(pSocket);
		write(pSocket, body);
	} else if(S_ISREG(filestat.st_mode)) {
		writeLine(pSocket, version + " 200 OK");
		writeLine(pSocket, "Content-Type: " + getContentType(path));
		string contentLength = to_string(filestat.st_size);
		writeLine(pSocket, "Content-Length: " + contentLength);
		writeLine(pSocket);
		writeFile(pSocket, path);
	} else if(S_ISDIR(filestat.st_mode)) {
		writeLine(pSocket, version + " 200 OK");
		writeLine(pSocket, "Content-Type: text/html");
		struct stat indexStat;
		string indexPath = joinPath(path, "index.html");
		if(stat(indexPath, indexStat) == ERROR) {
			string body = getDirectory(path, reqPath);
			writeLine(pSocket, "Content-Length: " + to_string(body.length()));
			writeLine(pSocket);
			write(pSocket, body);
		} else {
			writeLine(pSocket, "Content-Length: " + to_string(indexStat.st_size));
			writeLine(pSocket);
			writeFile(pSocket, indexPath);
		}
	}
}
TestRoadRunner::TestRoadRunner(const std::string& version, int caseNumber) :
                version(version), caseNumber(caseNumber), rr(0), simulation(0)
{
    //fileName = getModelFileName(version, caseNumber);

    home = getenv("HOME");
    dataOutputFolder = home + string("/tmp");
    string dummy;
    string logFileName;
    string settingsFileName;



    //Create a log file name
    createTestSuiteFileNameParts(caseNumber, ".log", dummy, logFileName, settingsFileName);

    //Create subfolder for data output
    dataOutputFolder = joinPath(dataOutputFolder, getTestSuiteSubFolderName(caseNumber));

    if(!createFolder(dataOutputFolder))
    {
        string msg("Failed creating output folder for data output: " + dataOutputFolder);
        throw(Exception(msg));
    }
}
示例#8
0
bool Game::loadSettings()
{
#ifdef NSPIRE
	#if defined(HOME_DIR)
		return settings.load(joinPath(lieroConfigRoot, settingsFile + ".DAT.tns"));
	#else
		return settings.load(joinPath(lieroDataRoot, settingsFile + ".DAT.tns"));
	#endif
#else
	#if defined(HOME_DIR)
		return settings.load(joinPath(lieroConfigRoot, settingsFile + ".DAT"));
	#else
		return settings.load(joinPath(lieroDataRoot, settingsFile + ".DAT"));
	#endif
#endif
}
示例#9
0
void Game::saveSettings()
{
#ifdef NSPIRE
	#if defined(HOME_DIR)
		settings.save(joinPath(lieroConfigRoot, settingsFile + ".DAT.tns"));
	#else
		settings.save(joinPath(lieroDataRoot, settingsFile + ".DAT.tns"));
	#endif
#else
	#if defined(HOME_DIR)
		settings.save(joinPath(lieroConfigRoot, settingsFile + ".DAT"));
	#else
		settings.save(joinPath(lieroDataRoot, settingsFile + ".DAT"));
	#endif
#endif
}
示例#10
0
bool CCompiler::compileSource(const string& sourceFileName)
{
    //Compile the code and load the resulting dll, and call an exported function in it...
#if defined(_WIN32) || defined(__CODEGEARC__)
    string dllFName(changeFileExtensionTo(getFileName(sourceFileName), "dll"));
#elif defined(__unix__)
    string dllFName(changeFileExtensionTo(getFileName(sourceFileName), "so"));
#elif defined(__APPLE__)
    string dllFName(changeFileExtensionTo(getFileName(sourceFileName), "dylib"));
#endif
    mDLLFileName = joinPath(getFilePath(sourceFileName), dllFName);

    //Setup compiler environment
    setupCompilerEnvironment();

    string exeCmd = createCompilerCommand(sourceFileName);

    //exeCmd += " > compileLog.log";
    Log(lDebug2)<<"Compiling model..";
    Log(lDebug)<<"\nExecuting compile command: "<<exeCmd;

    if(!compile(exeCmd))
    {
        Log(Logger::LOG_ERROR)<<"Creating DLL failed..";
        throw Exception("Creating Model DLL failed..");
    }

    //Check if the DLL exists...
    return fileExists(mDLLFileName);
}
示例#11
0
int env(int argc, char **argv) {
  char epath[PATH_MAX + 1];
  char *oldpath = getenv("PATH");

  assert(oldpath);

  if (!getExecutablePath(epath, sizeof(epath)))
    exit(EXIT_FAILURE);

  if (argc <= 1) {
    const std::string &pname = getParentProcessName();

    if (pname == "csh" || pname == "tcsh") {
      std::cerr << std::endl << "you are invoking this program from a C shell, "
                << std::endl << "please use " << std::endl << std::endl
                << "setenv PATH `" << epath << "/osxcross-env -v=PATH`"
                << std::endl << std::endl << "instead." << std::endl
                << std::endl;
    }
  }

  std::vector<std::string> path;
  std::map<std::string, std::string> vars;

  splitPath(oldpath, path);

  if (!hasPath(path, epath))
    path.push_back(epath);

  vars["PATH"] = joinPath(path);

  auto printVariable = [&](const std::string & var)->bool {
    auto it = vars.find(var);
    if (it == vars.end()) {
      std::cerr << "unknown variable '" << var << "'" << std::endl;
      return false;
    }
    std::cout << it->second << std::endl;
    return true;
  };

  if (argc <= 1) {
    std::cout << std::endl;
    for (auto &v : vars) {
      std::cout << "export " << v.first << "=";
      if (!printVariable(v.first))
        return 1;
      std::cout << std::endl;
    }
  } else {
    if (strncmp(argv[1], "-v=", 3))
      return 1;

    const char *var = argv[1] + 3;
    return static_cast<int>(printVariable(var));
  }

  return 0;
}
示例#12
0
QString getThumbnailsPath(){
    QString cachePath = QStandardPaths::standardLocations(QStandardPaths::CacheLocation).at(0);
    QString thumbnailPath = joinPath(cachePath, "thumbnails");
    if (!QDir(thumbnailPath).exists()){
        QDir(thumbnailPath).mkpath(thumbnailPath);
    }
    return thumbnailPath;
}
bool SBMLModelSimulation::SetModelFileName(const string& name)
{
    if(getFilePath(name).size() > 0)
    {
        mModelFilePath = getFilePath(name);
    }

    mModelFileName = getFileName(name);

    if(!fileExists(joinPath(mModelFilePath, mModelFileName)))
    {
        Log(Logger::LOG_ERROR)<<"The file: "<<joinPath(mModelFilePath, mModelFileName)<<" don't exist.";
        return false;
    }

    return true;
}
示例#14
0
void ServerConnection::recvDeleteFile( const QString &filename )
{
  qDebug() << "DeleteFile request for " << fSourceDir << filename;

  QFile file( joinPath(fSourceDir,filename) );
  if(!file.remove())
  {
    qDebug() << "Could not remove " << fSourceDir << filename;
  }
}
示例#15
0
void loadTablesFromEXE()
{
	
#ifdef NSPIRE
	FILE* exe = openFile(joinPath(lieroDataRoot, "sintab.dat.tns"));
#else
	FILE* exe = openFile(joinPath(lieroDataRoot, "sintab.dat"));
#endif
	
	for(int i = 0; i < 128; ++i)
	{
		cosTable[i] = readSint32(exe);
		sinTable[i] = readSint32(exe);
	}
	
	


}
示例#16
0
void Settings::generateName(WormSettings& ws)
{
#ifdef NSPIRE
	FILE* f = fopen(joinPath(lieroDataRoot, "NAMES.DAT.tns").c_str(), "rb");
#else
	FILE* f = fopen(joinPath(lieroDataRoot, "NAMES.DAT").c_str(), "rb");
#endif
	
	if(!f)
		return;
		
	std::vector<std::string> names;
	
	std::size_t len = fileLength(f);
	
	std::vector<char> chars(len);
	
	fread(&chars[0], 1, len, f);
	
	fclose(f);
	
	std::size_t begin = 0;
	for(std::size_t i = 0; i < len; ++i)
	{
		if(chars[i] == '\r'
		|| chars[i] == '\n')
		{
			if(i > begin)
			{
				names.push_back(std::string(chars.begin() + begin, chars.begin() + i));
			}
			
			begin = i + 1;
		}
	}
	
	if(!names.empty())
	{
		ws.name = names[gfx.rand(Uint32(names.size()))];
		ws.randomName = true;
	}
}
示例#17
0
 bool copyDirectory(const String& source, const String& dest)
 {
     try
     {
         HashSet<String> dirList(HashSet<String>::newInstance());
         if (!listDirectory(source, true, dirList))
             return false;
         
         createDirectory(dest);
         
         for (HashSet<String>::iterator file = dirList.begin(); file != dirList.end(); ++file)
             copyFile(joinPath(source, *file), joinPath(dest, *file));
     
         return true;
     }
     catch (...)
     {
         return false;
     }
 }
示例#18
0
    std::string PathHandler::findFile(const std::string& filename) const {
        StringList::const_iterator path = _paths.begin();
        for (; path != _paths.end(); ++path) {
            const std::string fullPath = joinPath(*path, filename);
            if (fileExists(fullPath)) {
                return fullPath;
            }
        }

        return filename;
    }
示例#19
0
bool rrcCallConv enableLoggingToFile(RRHandle handle)
{
    start_try
        char* tempFolder = getTempFolder(handle);
        string logFile = joinPath(tempFolder, "RoadRunner.log") ;
        rr::freeText(tempFolder);

        Logger::enableFileLogging(logFile);
        return true;
    catch_bool_macro
}
bool SBMLModelSimulation::SaveResult()
{
    string resultFileName(joinPath(mDataOutputFolder, "rr_" + mModelFileName));
    resultFileName = changeFileExtensionTo(resultFileName, ".csv");
    Log(lInfo)<<"Saving result to file: "<<resultFileName;
    RoadRunnerData resultData(mEngine);

    ofstream fs(resultFileName.c_str());
    fs << resultData;
    fs.close();
    return true;
}
示例#21
0
namespace rr
{

//Useful constants..
const char*     	gComma 			            = ",";
const char 	 		gTab 			            = '\t';
const char 	 		gNL 			            = '\n';
const char* 		gDoubleFormat 	            = "%f";
const char* 		gIntFormat  	            = "%d";;

const string    	gNoneString 				= "<none>";

//Observe, the following function, joinPath, is executed BEFORE any main..
const string		gDefaultSupportCodeFolder 	= joinPath("..", "rr_support");
const string		gDefaultTempFolder 			= ".";

const int 			gMaxPath					= 512;
const double    	gDoubleNaN   				= std::numeric_limits<double>::quiet_NaN() ;
const float     	gFloatNaN    				= std::numeric_limits<float>::quiet_NaN() ;

//Messages
const string		gEmptyModelMessage 			= "A model needs to be loaded before one can use this method";


#if defined(_WIN32) || defined(__CODEGEARC__)
const string		gDefaultCompiler 			= joinPath("..", "compilers", "tcc", "tcc.exe");
const char       	gPathSeparator      = '\\';
const string		gExeSuffix          = ".exe";
#elif defined(__unix__) || defined(__APPLE__)
// the default compiler on Unix systems is 'cc', the standard enviornment
// for the default compiler is 'CC'.
const string		gDefaultCompiler    = getenv("CC") ? getenv("CC") : "gcc";
const char       	gPathSeparator      = '/';
const string		gExeSuffix          = "";
#else  //Something else...
const char       	gPathSeparator      = '/';
const string		gExeSuffix          = "";
#endif

}
示例#22
0
/*called by timed capture [-c seconds] command line option*/
gboolean
Image_capture_timer(gpointer data)
{
    struct ALL_DATA * all_data = (struct ALL_DATA *) data;
    struct GLOBAL *global = all_data->global;
    struct GWIDGET *gwidget = all_data->gwidget;
    struct vdIn *videoIn = all_data->videoIn; 
    
    global->image_picn++;   

	if(global->image_inc > 0)
	{
		/*increment image name */
	    videoIn->ImageFName = incFilename(videoIn->ImageFName, 
    	    global->imgFPath,
    	    global->image_inc);
        
    	if(!global->no_display)
    	{
        	char *message = g_strjoin(" ", _("capturing photo to"), videoIn->ImageFName, NULL);
			gtk_statusbar_pop (GTK_STATUSBAR(gwidget->status_bar), gwidget->status_warning_id);
			gtk_statusbar_push (GTK_STATUSBAR(gwidget->status_bar), gwidget->status_warning_id, message);
			g_free(message);
    	}
    
    	global->image_inc++;
    }
    else
    	videoIn->ImageFName = joinPath(videoIn->ImageFName, global->imgFPath);
    
    videoIn->capImage = TRUE;

    if(global->image_picn >= global->image_npics) 
    {   /*destroy timer*/
        if(!global->no_display)
        {
            //gdk_threads_enter();
            gtk_button_set_label(GTK_BUTTON(gwidget->CapImageButt),_("Cap. Image"));
            set_sensitive_img_contrls(TRUE, gwidget);/*enable image controls*/
            gdk_flush();
            //gdk_threads_leave();
        }
        global->image_timer=0;
        global->image_picn=0;
        //if exit_on_close then shutdown
        if(global->exit_on_close)
            shutd (0, data);
        
        return (FALSE);
    }
    else return (TRUE);/*keep the timer*/
}
示例#23
0
VFS_NAMESPACE_START


ZipFile::ZipFile(const char *name, ZipArchiveRef *zref, unsigned int fileIdx)
: File(joinPath(zref->fullname(), name).c_str())
, _buf(NULL)
, _pos(0)
, _archiveHandle(zref)
, _bufSize(0)
, _fileIdx(fileIdx)
, _mode("rb") // binary mode by default
{
}
示例#24
0
void DiskDir::load()
{
    _files.clear();
    _subdirs.clear();
    // TODO: cache existing files and keep them unless they do no longer exist

    StringList li;
    GetFileList(fullname(), li);
    for(StringList::iterator it = li.begin(); it != li.end(); ++it)
    {
        DiskFile *f = new DiskFile(joinPath(fullname(), it->c_str()).c_str());
        _files[f->name()] = f;
    }

    li.clear();
    GetDirList(fullname(), li, 0);
    for(StringList::iterator it = li.begin(); it != li.end(); ++it)
    {
        // GetDirList() returns relative paths, so need to join
        Dir *d = createNew(joinPath(fullname(), it->c_str()).c_str());
        _subdirs[d->name()] = d;
    }
}
示例#25
0
void Game::generateLevel()
{
	if(settings.randomLevel)
	{
		level.generateRandom();
	}
	else
	{
		// TODO: Check .LEV as well as .lev
#ifdef NSPIRE
	#if defined(HOME_DIR)
			if(!level.load(joinPath(lieroConfigRoot, settings.levelFile + ".lev.tns")))
				level.generateRandom();
	#else
			if(!level.load(joinPath(lieroDataRoot, settings.levelFile + ".lev.tns")))
				level.generateRandom();
	#endif
#else
	#if defined(HOME_DIR)
			if(!level.load(joinPath(lieroConfigRoot, settings.levelFile + ".lev")))
				level.generateRandom();
	#else
			if(!level.load(joinPath(lieroDataRoot, settings.levelFile + ".lev")))
				level.generateRandom();
	#endif
#endif
	}
	
	oldRandomLevel = settings.randomLevel;
	oldLevelFile = settings.levelFile;
	
	if(settings.shadow)
	{
		level.makeShadow();
	}
}
示例#26
0
File *Dir::getFileByName(const char *fn, bool lazyLoad /* = true */)
{
    Files::iterator it = _files.find(fn);
    if(it != _files.end())
        return it->second;

    if(!lazyLoad || !_loader)
        return NULL;

    // Lazy-load file if it's not in the tree yet
    std::string fn2 = joinPath(fullname(), GetBaseNameFromPath(fn));
    File *f = _loader->Load(fn2.c_str(), fn2.c_str());
    if(f)
        _files[f->name()] = f;
    return f;
}
示例#27
0
//////////////////////////////////////////////////////////////////////////
/// Add a FileSystemWatcher to the directory
/// 
/// Creates a FileSystemWatcher, connects all the signals, adds it to the
/// list of watchers and starts it.
//////////////////////////////////////////////////////////////////////////
void SyncSystem::slotStartNodeWatching(const QString& dir)
{
  QString watchDir = joinPath(m_CurrentSourcePath, dir);
  qDebug() << "[SyncSystem.Debug] slotStartNodeWatching in dir " << watchDir;

  FileSystemWatcher* watcher = new FileSystemWatcher();
  connect(watcher, SIGNAL(fileAdded(QString)), SLOT(slotFileAdded(QString)));
  connect(watcher, SIGNAL(fileDeleted(QString)), SLOT(slotFileDeleted(QString)));
  connect(watcher, SIGNAL(fileChanged(QString)), SLOT(slotFileChanged(QString)));
  connect(watcher, SIGNAL(fileRenamed(QString,QString)), SLOT(slotFileRenamed(QString,QString)));
  connect(watcher, SIGNAL(filewatchError(QString)), SLOT(slotFilewatchError(QString)));
  connect(watcher, SIGNAL(filewatchLostSync(QString)), SLOT(slotLostSync()));
  m_FileSystemWatchers.append(watcher);
  watcher->setWatchDir(watchDir);
  watcher->setRelativeDir(dir);
  watcher->start();
}
示例#28
0
void* handleConnection(void* connPtr){
	struct ConnInfo conn = *((struct ConnInfo*)connPtr);
	int pSocket = conn.socket;
	string root = conn.root;
	linger lin;
	unsigned int y=sizeof(lin);
	lin.l_onoff=1;
	lin.l_linger=10;
	setsockopt(pSocket,SOL_SOCKET, SO_LINGER,&lin,sizeof(lin));
	struct Request request = getRequest(pSocket);
	string path = joinPath(root, request.path);
	respond(pSocket, request.version, path, request.path);
	shutdown(pSocket, SHUT_RDWR);
	if(close(pSocket) == ERROR) {
		errorOut("Couldn't close message socket");
	}
}
示例#29
0
string getDirectory(string path, string reqPath) {
	DIR* dirp;
	struct dirent *dp;
	string start = "<!DOCTYPE html><html><head></head><body>";
	string chunkStart = "<a href='";
	string chunkMiddle = "'>";
	string chunkEnd = "</a></br>";
	string end = "</body></html>";
	dirp = opendir(path.c_str());
	string result = start;
	while((dp = readdir(dirp)) != NULL) {
		string itemReqPath = joinPath(reqPath, string(dp->d_name));
		result += chunkStart + itemReqPath + chunkMiddle + string(dp->d_name) + chunkEnd;
	}
	(void)closedir(dirp);
	result += end;
	return result;
}
示例#30
0
//////////////////////////////////////////////////////////////////////////
/// Send a file to the server, replacing \r\n with \n for text files.
/// 
/// Creates the timers and connects the signals.
/// Does the initial connection to the server before entering the event 
/// loop.
//////////////////////////////////////////////////////////////////////////
void SyncSystem::sendFile( const QString &filename, bool binary, bool executable )
{
  //Get the source and destination directory from the branch information
  if(m_CurrentSourcePath.isEmpty())
  {
//     QString infoString("Missing source path for branch");
//     QMessageBox::information(this, "Information", infoString, "Ok", "", "");
    return;
  }

  QString path = joinPath(m_CurrentSourcePath,filename);
  QFile file( path );

  if( file.open(QIODevice::ReadOnly) )
  {
    QFileInfo fileinfo( file );

    QByteArray data = file.readAll();
    if( !binary )
    {
      // 0d 0a -> 0a
      char *src = data.data();
      char *dst = data.data();
      char *srcend = src + data.size();
      //int state = 0;
      while( src != srcend )
      {
        if( *src != 0x0d )
        {
          *dst++ = *src;
        }
        src++;
      }
      data.resize( static_cast<int>(dst-data.data()) );
    }
    m_Connection->sendSendFile( filename, fileinfo.lastModified(), data, executable );
  }
  else
  {
    qWarning() << "[SyncSystem.sendFile] Could not open file " << filename;
    addTodo(filename, binary, executable, false, true);
  }
}