void 
FileLogHandler::writeFooter()
{
  static int callCount = 0;
  m_pLogFile->writeChar(getDefaultFooter());
  /**
   * The reason I also check the number of log entries instead of
   * only the log size, is that I do not want to check the file size
   * after each log entry which requires system calls and is quite slow.
   * TODO: Any better way?
   */
  if (callCount % m_maxLogEntries != 0) // Check every m_maxLogEntries
  {
    if (isTimeForNewFile())
    {
      if (!createNewFile())
      {
	// Baby one more time...
	createNewFile();
      }
    }	
    callCount = 0;
  }
  callCount++;

  m_pLogFile->flush();
}
Ejemplo n.º 2
0
Toerstein::Toerstein(QWidget *parent) : QMainWindow(parent)
{
    toersteBase = new ToersteBase(this);
    toerstelliSense = new ToerstelliSense(this,toersteBase);

    connect(this,SIGNAL(fileLoaded(QString)),toerstelliSense->worker(),SLOT(indexFile(QString)));

    createMenuBar();
    createShortcuts();

    /* Create tab view */
    tabView = new TabView(this);
    tabView->setTabsClosable(true);
    setCentralWidget(tabView);

    connect(tabView,SIGNAL(tabCloseRequested(int)),this,SLOT(closeTab(int)));

    QCommandLineOption diffMode(QStringList() << "d" << "diff");
    QCommandLineParser parser;

    parser.addOption(diffMode);
    parser.process(QCoreApplication::arguments());

    const QStringList args = parser.positionalArguments();

    if ( args.length() > 0 )
    {
        if ( parser.isSet(diffMode) )
        {
            createNewFile();

            if ( args.length() > 1 )
            {
                open(args.at(0), args.at(1));
            }
            else
            {
                open(args.at(0));
            }
        }
        else
        {
            for(int i=0; i < args.length(); i++)
            {
                createNewFile();
                open(args.at(i));
            }
        }
    }
    else
    {
        createNewFile();
    }
}
Ejemplo n.º 3
0
/**
 * @brief readField returns the data readed on field of the database.
 * @param pFile is the name of the file to be readed from.
 * @param pRow is the row of the desired data.
 * @param Column is the column of the desired data.
 * @return
 */
string readfile::readField(string pFile , int pRow , int pColumn){
    int currSeek =file.tellg();
    int sizeToColumn;
    int cSize;
    //Relative route + the name of the file
    if ( !(file.is_open()) ){
        string standardDir = createNewFile(&pFile);
        file.open(standardDir.c_str());
    }

    if ( !(file.is_open()) ){
        return "NED " + pFile;
    }

   placeSeekOn(&pRow , &pColumn, &sizeToColumn, &cSize);

    //build the stringto return
    string stringToReturn = "";

    for (int i  = 0 ; i < cSize ; i++){
        char currChar = file.get();
        if (currChar != '*'){
            stringToReturn.push_back(currChar);
        }else{
            break;
        }
    }
    file.seekg(currSeek);
    if (stringToReturn == "") stringToReturn = "404";
    return stringToReturn;
}
Ejemplo n.º 4
0
void Toerstein::createShortcuts(void)
{
    QShortcut *shortcut;

    /* In QMenuBar shortcuts won't work if menuBar is not visible,
     * so we'll add them separately here
     */

    /* Shortcuts to File-menu */
    shortcut = new QShortcut(QKeySequence(tr("Ctrl+T", "File|New Tab")),this,SLOT(createNewTab()));
    shortcut->setAutoRepeat(false);
    shortcut = new QShortcut(QKeySequence(tr("Ctrl+N", "File|New File")),this,SLOT(createNewFile()));
    shortcut->setAutoRepeat(false);
    shortcut = new QShortcut(QKeySequence(tr("Ctrl+O", "File|Open File")),this,SLOT(open()));
    shortcut->setAutoRepeat(false);
    shortcut = new QShortcut(QKeySequence(tr("Ctrl+P", "File|Enter File Path") ),this,SLOT(search()));
    shortcut->setAutoRepeat(false);
    shortcut = new QShortcut(QKeySequence(tr("Ctrl+S", "File|Save File") ),this,SLOT(save()));
    shortcut->setAutoRepeat(false);
    shortcut = new QShortcut(QKeySequence(tr("Ctrl+W", "File|Close File") ),this,SLOT(closeFile()));
    shortcut->setAutoRepeat(false);
    shortcut = new QShortcut(QKeySequence(tr("Ctrl+Q", "File|Quit")),this,SLOT(close()));
    shortcut->setAutoRepeat(false);

    /* Shortcuts to View-menu */
    shortcut = new QShortcut(QKeySequence(tr("Ctrl+D", "Toggle Diff View|Quit")),this,SLOT(toggleViewMode()));
    shortcut->setAutoRepeat(false);
}
Ejemplo n.º 5
0
/**
 * @brief updateField changes the value of a  given field on the whole database.
 * @param newData new information to be inserted.
 * @param pFile the database to be used
 * @param pRow
 * @param pColumn
 */
bool writefile::updateField(string newData, string pFile , int pRow , int pColumn){
    int currSeek = file.tellg();
    int sizeToColumn;
    int cSize;
    bool bowl = true;
    //Relative route + the name of the file
    if ( !(file.is_open()) ){
        string fileH = pFile;
        string standardDir = createNewFile(fileH.c_str());
        file.open(standardDir.c_str());
    }

    if ( !(file.is_open()) ){
        cout << "NED " + pFile << endl;
        bowl = false;
    }

    placeSeekOn(&pRow , &pColumn, &sizeToColumn, &cSize);
    fillString(&newData,cSize);


    if (file.is_open()){
        file << newData;
    }

    file.seekg(currSeek);

    if (file.is_open()){
        file.close();
    }
    return bowl;
}
Ejemplo n.º 6
0
/**
 * @brief readColumn return all the values on a named column
 * @param pFile is the database to be readed from.
 * @param pColumnName parameter for returning a value.
 * @return
 */
array<char*> readfile::readColumn(string pFile , string pColumnName){
    string standardDir;
    array <char*> errorArray (ONE_BYTE);   //if !database, return null array

    if ( !(file.is_open()) ){
        standardDir = createNewFile(&pFile);
        file.open(standardDir.c_str());
    }

    if ( !(file.is_open()) ){
        cout << "NED " + pFile << endl;
        return errorArray;
    }

    int Column = getColumnNumber(&standardDir , &pColumnName );
    int regQty = getRegisterQuantity();
    string strToConvert = EMPTY_STRING;
    char * toAdd;
    array <char*> arrayToReturn (regQty);

    for (int rowCounter = ONE_BYTE ; rowCounter <= regQty ; rowCounter++){
        strToConvert = readField(pFile , rowCounter , pColumnName);
        toAdd = new char[strToConvert.size()+1];
        strcpy(toAdd, strToConvert.c_str());
        arrayToReturn[rowCounter - ONE_BYTE] = toAdd;
    }
    return arrayToReturn;
}
Ejemplo n.º 7
0
/**
 * @brief readRegistry return all the values for a required registry.
 * @param pFile the database to be consulted.
 * @param pRegister the row to be consulted.
 * @return
 */
array< char* > readfile::readRegistry(string pFile , int pRegister){
    array< char* > errorArray (1);
    string standardDir = "open";
    //Relative route + the name of the file
    if ( !(file.is_open()) ){
        standardDir = createNewFile(&pFile);
        file.open(standardDir.c_str());
    }
    //cout << standardDir << endl;

    if ( !(file.is_open()) ){
        cout << NO_EXISTANT_DATA + pFile << endl;
        return errorArray;
    }

    //Create an array that will contain all the columns
    int columnQty = (getMetaDataSize() - METADATA_COLUMN_START)
                    / DEFAULT_COLUMN_SIZE;

    array < char* > arrayToReturn (columnQty);
    string tempString = EMPTY_STRING;
    char* toAdd;
    for (int i = ZE_ROW; i < columnQty; i++){
        tempString = readField(pFile , pRegister , i+1);
        toAdd = new char[tempString.size()+1];
        strcpy(toAdd, tempString.c_str());
        arrayToReturn[i] = toAdd;
    }

    file.close();
    return arrayToReturn;
}
Ejemplo n.º 8
0
/**
 * @brief writefile::restoreFile
 * @param fileToRestore
 */
void writefile::restoreFile(string fileToRestore){
    string backUp= "backup";
    backUp.append(fileToRestore);

    string pathFileToRestore = createNewBackUp(backUp);
    string pathRestoredFile = createNewFile(fileToRestore);

    ofstream newfile (pathRestoredFile.c_str() , ios::trunc);
    newfile.close();


    std::ifstream ifs(pathFileToRestore.c_str(), std::ios::binary);
    std::ofstream ofs(pathRestoredFile.c_str(), std::ios::binary);

    ofs << ifs.rdbuf();

    ifs.close();
    ofs.close();

    pathFileToRestore.append("Columns");
    pathRestoredFile.append("Columns");

    ofstream newfile2 (pathRestoredFile.c_str() , ios::trunc);
    newfile2.close();

    std::ifstream ifs2(pathFileToRestore.c_str(), std::ios::binary);
    std::ofstream ofs2(pathRestoredFile.c_str(), std::ios::binary);

    ofs2 << ifs2.rdbuf();

    ifs2.close();
    ofs2.close();
}
Ejemplo n.º 9
0
void writefile::backUpFile(string fileTobackUp){
    string backUp= "backup";
    backUp.append(fileTobackUp); //backupTest8

    string pathFileToBackUp = createNewFile(fileTobackUp); //../FSQL/Test8
    string pathbackUpFile = createNewBackUp(backUp);// ../FSQL/backupTest8

    ofstream newfile (pathbackUpFile.c_str() , ios::trunc);
    newfile.close();

    std::ifstream ifs(pathFileToBackUp.c_str(), std::ios::binary);
    std::ofstream ofs(pathbackUpFile.c_str(), std::ios::binary);

    ofs << ifs.rdbuf();

    ifs.close();
    ofs.close();

    pathFileToBackUp.append("Columns");
    pathbackUpFile.append("Columns");

    ofstream newfile2 (pathbackUpFile.c_str() , ios::trunc);
    newfile2.close();

    std::ifstream ifs2(pathFileToBackUp.c_str(), std::ios::binary);
    std::ofstream ofs2(pathbackUpFile.c_str(), std::ios::binary);

    ofs2 << ifs2.rdbuf();

    ifs2.close();
    ofs2.close();
}
Ejemplo n.º 10
0
Stream * ZipArchive::openFile(const char *filename, ZipEntry* ze, AccessMode mode /* = Read */)
{
   if(mode == Read)
   {
      if(ze == NULL)
         return NULL;

      return openFileForRead(&ze->mCD);
   }

   if(mode == Write)
   {
      if(ze)
      {
         if(ze->mCD.mInternalFlags & CDFileOpen)
         {
            if(isVerbose())
               Con::errorf("ZipArchive::openFile - File %s is already open", filename);
            return NULL;
         }
         
         // Remove the old entry so we can create a new one
         removeEntry(ze);
         ze = NULL;
      }

      return createNewFile(filename, Compressor::findCompressor(Deflated));
   }

   if(isVerbose())
      Con::errorf("ZipArchive::openFile - Files within zips can only be opened as read or write, but not both at the same time.");

   return NULL;
}
Ejemplo n.º 11
0
/**
 * Start the process of creating a new file.  Asks the user where to create
 * it and what to name it.  If this is completed successfully, emit the
 * newFile() signal.
 */
void QQMenuHelper::emitNewFile()
{
    QString filename = createNewFile(description, extension);
    if (filename.isEmpty()) {
        return;
    }
    emit(newFile(filename));
}
Ejemplo n.º 12
0
/**
 * @brief createTable creates the database and metadata.
 * @param registerSize is the size for each registry.
 * @param columnSizes is the sizes for each column.
 */
bool writefile::createTable(int* registerSize, array<int>* columnSizes ,
                            array<char*>* columnNames , string* pFile){

    int offset = 0;
    string add;

    string theFileName = createNewFile(*pFile);
    writefile::writeColumnNames(&theFileName, columnNames);
    ofstream database (theFileName.c_str() , ios::trunc);

    //check if buffer = true
    if(database.is_open()){
        //cout << "****Database succesfully created***" << endl;
    }else{
        //cout << "****Database could not be created***" << endl;
        return false;
    }

    //Register size valideichion.
    if(*registerSize >= K->MAX_REGISTER_SIZE){
        cout << "Error: Register size beyond max size" << endl;
        return false;
    }else{
        database << K->TRIPLE_NULL;
        add = toChar(*registerSize);
        checkSize(&add, K->DEFAULT_REGISTER_SIZE);
        database.write(add.c_str() , K->DEFAULT_REGISTER_SIZE);
    }

    //set column sizes on file
    array<int> tempArr = *columnSizes;
    for (int i = 0 ; i < tempArr.getLenght() ; i++)
    {
        int integerElem = tempArr[i];
        add = toChar(integerElem);
        checkSize(&add,K->DEFAULT_COLUMN_SIZE);
        database.write(add.c_str() , K->DEFAULT_COLUMN_SIZE);
    }

    //sets seek on the end, gets the address then turns it to char
    //to insert on the beginning.
    database.seekp(offset, ios::end);
    int meta = database.tellp();
    string metadata = intToChar(meta);
    checkSize(&metadata, K->METADATA_SIZE);
    database.seekp(K->ZE_ROW);
    if (metadata.length() <= 3){
        const char *p = metadata.c_str();
        while (*p != '\0')
            database.put( *(p++) );
    }else{
        //cout << "Invalid metadata size. Yoh ! Pls kontact ur admin...\n";
        return false;
    }
    database.seekp(K->ZE_ROW , ios::end);
    database.close();
    return true;
}
Ejemplo n.º 13
0
bool File::truncate()
{
  if (exists()) {
    if (!remove()) {
      return false;
    }
  }
  return createNewFile();
}
Ejemplo n.º 14
0
void Sudoku::fileOutput() const
{
	string file = promptForString("What file would you like to write to? "); // Get user-specified file
	ofstream out; 
	if(createNewFile(out, file)) // Create file and write to it
	{
		out << toString();
		out.close();
	}
}
Ejemplo n.º 15
0
/**
 * @brief writeRegister Method to append a whole registry. Add new element to database.
 * @param pFileName is the name of database file to add to.
 * @param pColumnData it's what to append.
 * @param columnPos is where to append it.
 */
bool writefile::writeRegister(string pFileName, array<char*>* pColumnData ,
                              array<char*>* pColumnNam){

    int currSeek = file.tellg();
    string standardDir = createNewFile(pFileName);
    file.open(standardDir.c_str());
    bool isOpen = true;

    if(!file.is_open()){
        cout << "NED "  + pFileName << endl;
        return false;
    }

    file.seekg(K->ZE_ROW);

    int spacesToMove;
    int Csize;
    int lon = pColumnNam->getLenght();

    array<char*> tempCDataArr = *pColumnData;
    array<char*> tempNames = *pColumnNam;
    array<int> ColumnPos (lon);

    string registerToWrite = K->EMPTY_STRING;
    string Cdata;

    const char* charT ;

    for (int i = K->ZE_ROW ; i < lon ; i++){
        charT  = tempNames[i];
        string strToAdd(charT);
        ColumnPos[i] = getColumnNumber(&pFileName, &strToAdd);
    }

    //Get the register and fill the blanks.
    fillString (&registerToWrite , getRegisterSize());

    for (int i = 0 ; i < ColumnPos.getLenght() ; i++){
        Cdata  = tempCDataArr[i];
        checkString(&Cdata);
        Csize = columnSize(ColumnPos[i]);
        //Not sure
        spacesToMove = sizeUntilColumn(ColumnPos[i]);
        fillString(&Cdata ,Csize);
        registerToWrite.replace(spacesToMove , Csize , Cdata.c_str());
    }

    if (file.is_open()){
        file.seekg(K->ZE_ROW , ios::end);
        file << registerToWrite;
    }
    file.seekg(currSeek);
    file.close();
    return isOpen;
}
Ejemplo n.º 16
0
/**
 * @brief updateColumn From pCname of pFile, replace pToCompare with newData
 * @param newData
 * @param pToCompare
 * @param pFile
 * @param pCName
 */
bool writefile::updateColumn(string newData,string pToCompare, string pFile, string pCName){

    int currSeek = file.tellg();
    int sizeToColumn;
    int cSize;
    string standardDir;
    bool bowl = true;

    //Relative route + the name of the file
    if ( !(file.is_open()) ){
        string fileH = pFile;
        standardDir = createNewFile(fileH.c_str());
        file.open(standardDir.c_str());
    }

    if ( !(file.is_open()) ){
        cout << "NED " + pFile << endl;
        bowl = false;
    }

    int Column = getColumnNumber(&standardDir , &pCName );
    int regQty = getRegisterQuantity();
    string currentData = K->EMPTY_STRING;

    for (int rowCounter = K->ONE_BYTE ; rowCounter <= regQty ; rowCounter++){

        //Move the seek to the column and register.
        placeSeekOn( &rowCounter , &Column, &sizeToColumn, &cSize);

        //Build the string of the old data
        for (int i = 0 ; i < cSize ; i++){
            char temp = file.get();
            if (temp == '*'){
                break;
            }else{
                currentData.push_back(temp);
            }
        }
        //Compare data.
        if (currentData == pToCompare){
            updateField(newData, pFile , rowCounter , Column);
        }else{
            currentData = K->EMPTY_STRING;
        }
    }

    file.seekg(currSeek);
    if (file.is_open()){
        file.close();
    }
    return bowl;
}
Ejemplo n.º 17
0
// Select a file from the filesystem to use.
File &STORAGE::Filesystem::select(std::string fname) {
	std::lock_guard<std::mutex> lk(selectLock);

	bool fileExists = exists(fname);

	// Check if the file exists.
	if (!fileExists) {
		// This potentially creates garbage if the user doesn't ever write to the file
		createNewFile(fname);
	}

	return lookup[fname];
}
Ejemplo n.º 18
0
bool Forest::onAdd()
{
   if (!Parent::onAdd())
      return false;

   const char *name = getName();
   if(name && name[0] && getClassRep())
   {
      Namespace *parent = getClassRep()->getNameSpace();
      Con::linkNamespaces(parent->mName, name);
      mNameSpace = Con::lookupNamespace(name);
   }

   setGlobalBounds();
   resetWorldBox();

   // TODO: Make sure this calls the script "onAdd" which will
   // populate the object with forest entries before creation.
   addToScene();

   // If we don't have a file name and the editor is 
   // enabled then create an empty forest data file.
   if ( isServerObject() && ( !mDataFileName || !mDataFileName[0] ) )
      createNewFile();
   else
   {
      // Try to load the forest file.
      mData = ResourceManager::get().load( mDataFileName );
      if ( !mData )
      {
         if ( isClientObject() )
            NetConnection::setLastError( "You are missing a file needed to play this mission: %s", mDataFileName );

         return false;
      }
   }

   updateCollision();

   smCreatedSignal.trigger( this );

   if ( isClientObject() )
   {
      mZoningDirty = true;
      SceneZoneSpaceManager::getZoningChangedSignal().notify( this, &Forest::_onZoningChanged );

      ForestWindMgr::getAdvanceSignal().notify( this, &Forest::getLocalWindTrees );
   }

   return true;
}
Ejemplo n.º 19
0
int FileLoader::load(ETLDataExtractionType &buffer_in)
{
    int load_result = ETLInfo::ETL_SUCCESS;

    if ( !m_fileToLoad.isOpen() )
    {
        load_result = createNewFile();
    }
    else
    {
        if ( m_maxFileSize < ( m_fileToLoad.size() + buffer_in.first + (int)sizeof(SegmentHeaderType)) )
        {
            m_fileToLoad.close();
            load_result = createNewFile();
        }
    }

    if( ETLInfo::ETL_SUCCESS == load_result ||
        ETLInfo::ETL_SUCCESS_NEW_FILE == load_result )
    {
        SegmentHeaderType write_header;
        write_header.segmentSize = buffer_in.first;

        int write_result = m_fileToLoad.write((char*)&write_header, sizeof(SegmentHeaderType));

        if( -1 != write_result )
        {
            write_result = m_fileToLoad.write(buffer_in.second.get(), buffer_in.first);
        }

        if ( -1 == write_result )
        {
            load_result = ETLInfo::ETL_CANNOT_WRITE_FILE;
        }
    }

    return load_result;
}
Ejemplo n.º 20
0
bool writefile::deleteRegister(string pFile, string pCName, string newData){
    int currSeek = file.tellg();
    int Column;
    int cSize;
    string standardDir;
    bool bowl = true;

    //Relative route + the name of the file
    if ( !(file.is_open()) ){
        standardDir = createNewFile(pFile.c_str());
        file.open(standardDir.c_str());
    }

    if ( !(file.is_open()) ){
        cout << "NED " + pFile << endl;
        return false;
    }

    Column = getColumnNumber(&standardDir , &pCName );
    cSize = getRegisterSize();
    int regQty = getRegisterQuantity();
    string voidField = K->EMPTY_STRING;
    int sizeToColumn = sizeUntilColumn(Column);

    fillString(&voidField,cSize);
    cout << voidField.length() <<endl;
    for (int rowCounter = K->ONE_BYTE ; rowCounter <= regQty ; rowCounter++){

        //Compare data.
        if (readField(pFile , rowCounter , Column) == newData){
            placeSeekOn(&rowCounter , &Column, &sizeToColumn, &cSize);
            if (file.is_open()){
                file << voidField;
            } else {
                bowl = false;
            }
        }
    }

    file.seekg(currSeek);
    if (file.is_open()){
        file.close();
    }
    return bowl;
}
void FileManager::setupActions()
{
    KAction* action = new KAction(this);
    action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
    action->setText(i18n("Current Document Directory"));
    action->setIcon(KIcon("dirsync"));
    connect(action, SIGNAL(triggered(bool)), this, SLOT(syncCurrentDocumentDirectory()));
    tbActions << (dirop->actionCollection()->action("back"));
    tbActions << (dirop->actionCollection()->action("up"));
    tbActions << (dirop->actionCollection()->action("home"));
    tbActions << (dirop->actionCollection()->action("forward"));
    tbActions << (dirop->actionCollection()->action("reload"));
    tbActions << action;
    tbActions << (dirop->actionCollection()->action("sorting menu"));
    tbActions << (dirop->actionCollection()->action("show hidden"));

    newFileAction = new KAction(this);
    newFileAction->setText(i18n("New File..."));
    newFileAction->setIcon(KIcon("document-new"));
    connect(newFileAction, SIGNAL(triggered()), this, SLOT(createNewFile()));
}
Ejemplo n.º 22
0
void readLoop(socklen_t socket) {
    uint8_t header[HEADER_SIZE];
    uint8_t msg[MSG_SIZE];
    uint16_t length = 0;
    struct msgheader headerstr;
    FILE* fd;

    fd = createNewFile(par.path);
    while(1) {
        if(length == 0) {
            if(readHeader(socket, header) < 0)
                return;
            writeToFile(fd, header, HEADER_SIZE);
            
            headerstr = parseHeader(header);
            bytecounter += ntohs(headerstr.length);
            length = ntohs(headerstr.length)-HEADER_SIZE;
        }

        if(length >= MSG_SIZE) {
            if(readMsg(socket, msg, MSG_SIZE) < 0)
                return;

            writeToFile(fd, msg, MSG_SIZE);
            length-=MSG_SIZE;
        }
        else {
            if(readMsg(socket, msg, length) < 0)
                return;
            writeToFile(fd, msg, length);
            length = 0;
        }

        if ((bytecounter >= par.size) && (length == 0)) {
            bytecounter = 0;
            fclose(fd);
            close(socket);
        }
    }
}
Ejemplo n.º 23
0
array< array<char*> > readfile::getRegisters(string pFile, string pColumnName,
                                             string valueToConsult){
    string standardDir;
    int regs = getRegisterQuantity();
    int colNum;

    if ( !(file.is_open()) ){
        standardDir = createNewFile(&pFile);
        file.open(standardDir.c_str());
    }

    colNum = getColumnNumber(&standardDir, &pColumnName);

    array< array<char*> > select (getRegisterQuantity());

    for ( int i = ZE_ROW ; i < regs ; i ++){
        if(valueToConsult == readField(pFile,i+1,colNum)){
            select [i] = readRegistry( pFile , colNum);
        }
    }
    return select;
}
Ejemplo n.º 24
0
void Toerstein::createMenuBar(void)
{
    QMenuBar *menuBar = new QMenuBar(this);
    menuBar->setVisible(false);

    /* Create File menu */
    QMenu *fileMenu = menuBar->addMenu(tr("&File"));

    fileMenu->addAction( tr("New &Tab"), this, SLOT(createNewTab()) );
    fileMenu->addAction( tr("&New"), this, SLOT(createNewFile()) );
    fileMenu->addAction( tr("&Open"), this, SLOT(open()) );
    fileMenu->addAction( tr("Enter File &Path"), this, SLOT(search()) );
    fileMenu->addAction( tr("&Save"), this, SLOT(save()) );
    fileMenu->addAction( tr("Save As..."), this, SLOT(saveAs()) );
    fileMenu->addAction( tr("&Close File"), this, SLOT(closeFile()) );
    fileMenu->addAction( tr("&Quit"), this, SLOT(close()) );

    QMenu *viewMenu = menuBar->addMenu(tr("&View"));
    viewMenu->addAction( tr("Toggle &Diff View"), this, SLOT(toggleViewMode()) );

    this->setMenuBar(menuBar);
}
Ejemplo n.º 25
0
BufferID Notepad_plus::openFileThatIsntOpenedYet(NotepadFile& notepadFile,  bool isReadOnly)
{
	removeFromRecentFileList(notepadFile);

	if (notepadFile.isFileSession() && notepadFile.exists()) {
		fileLoadSession(notepadFile);
		return BUFFER_INVALID;
	}

	TemporaryWow64FsRedirectionSwitch wow64FsRedirectionSwitch;
	if (!notepadFile.exists())
		wow64FsRedirectionSwitch.switchOff();

	if (!notepadFile.exists())
		if (!createNewFile(notepadFile))
			return BUFFER_INVALID;

	if (notepadFile.isDirectory())
		return openAllFilesInDirectory(notepadFile);

	return openNormalFile(notepadFile, isReadOnly);
}
Ejemplo n.º 26
0
int readfile::getRaidMode(string* pFile){
    int currSeek = file.tellg();

    //Relative route + the name of the file
    if ( !(file.is_open()) ){
        string standardDir = createNewFile(pFile);
        file.open(standardDir.c_str());
    }

    if ( !(file.is_open()) ){
        cout << NO_EXISTANT_FILE <<endl;
        return -1;
    }

    string raid;
    file.seekg(RAID_MODE_START);
    for (short i = ZE_ROW; i < 2 ; i++){
        raid.push_back(file.get());
    }
    int RD = stringToInt(&raid);
    file.seekg(currSeek);
    return RD;
}
bool
FileLogHandler::open()
{
  bool rc = true;

  if (m_pLogFile->open())
  {
    if (isTimeForNewFile())
    {
      if (!createNewFile())
      {
	setErrorCode(errno);
	rc = false; 
      }
    }
  }
  else
  {
    setErrorCode(errno);
    rc = false;
  }

  return rc;
}
Ejemplo n.º 28
0
std::string		UsualInterface::makeBehavior(void) {
	createNewFile("interface", path + "/include/" + genMapName["${CLASS_NAME}"] + ".hpp", genMapName, loopMapName);
	addToFile("INTERFACE", genMapName["${CLASS_NAME}"], path + "/Makefile", false);
	return ("Interface " + genMapName["${CLASS_NAME}"] + " created successfully!");
}
Ejemplo n.º 29
0
void CabbageProjectWindow::buttonClicked (Button* button)
{
    createNewFile (button->getName());
}
Ejemplo n.º 30
0
/*
 * NewFile - load up a new file
 */
vi_rc NewFile( char *name, bool same_file )
{
    vi_rc       rc;
    bool        dup;
    status_type oldstatus;

    dup = EditFlags.DuplicateFile;
    EditFlags.DuplicateFile = false;
    oldstatus = UpdateCurrentStatus( CSTATUS_READING );

    ScreenPage( 1 );
#ifdef __WIN__
    EditFlags.ResizeableWindow = true;
#endif
    rc = createNewFile( name, same_file );
    if( rc != ERR_NO_ERR && rc != NEW_FILE ) {
        ScreenPage( -1 );
        if( !EditFlags.Starting ) {
            MoveWindowToFrontDammit( MessageWindow, true );
            MoveWindowToFrontDammit( CurrentWindow, true );
        }
        UpdateCurrentStatus( oldstatus );
        return( rc );
    }
    GoToLineNoRelCurs( 1 );
    GoToColumnOnCurrentLine( 1 );
    FileSPVAR();
    SaveCurrentInfo();
    if( !same_file ) {
        inReadHook++;
        rc = SourceHook( SRC_HOOK_READ, rc );
        inReadHook--;
    }

    /*
     * back from hook, so all loadings are done
     * (who should have priority - hook or fts commands?)
     */
#if 0
    rc = FTSRunCmds( CurrentFile->name );
    FTSRunCmds( CurrentFile->name );
#endif

    /*
     * reset the screen to the display page, display everything
     */
    ScreenPage( -1 );
    MoveWindowToFrontDammit( CurrentWindow, true );
    UpdateStatusWindow();
    SetWindowCursor();
    DCDisplayAllLines();
    EditFlags.DuplicateFile = dup;
    DisplayFileStatus();
    SaveCurrentInfo();
    ActiveWindow( CurrentWindow );
    VarAddRandC();
    SetModifiedVar( false );
    UpdateCurrentStatus( oldstatus );
    if( !same_file && !inReadHook ) {
        UpdateLastFileList( CurrentFile->name );
    }
#ifdef __WIN__
    DCUpdateAll();
    ResetEditWindowCursor( CurrentWindow );
    SetWindowCursorForReal();
    GotoFile( CurrentWindow );
#endif
    return( rc );

} /* NewFile */