예제 #1
0
//displays the array and writes to a file
void checkarray(void)
{
	string line1='\n';
	int line2=strlen(line1);

	displayTextLine(2,"%c,%c,%c,%c,%c,%c,%c,%c,%c",grid[6][0],grid[6][1],grid[6][2],grid[6][3],grid[6][4],grid[6][5],grid[6][6],grid[6][7],grid[6][8]);
	displayTextLine(3,"%c,%c,%c,%c,%c,%c,%c,%c,%c",grid[5][0],grid[5][1],grid[5][2],grid[5][3],grid[5][4],grid[5][5],grid[5][6],grid[5][7],grid[5][8]);
	displayTextLine(4,"%c,%c,%c,%c,%c,%c,%c,%c,%c",grid[4][0],grid[4][1],grid[4][2],grid[4][3],grid[4][4],grid[4][5],grid[4][6],grid[4][7],grid[4][8]);
	displayTextLine(5,"%c,%c,%c,%c,%c,%c,%c,%c,%c",grid[3][0],grid[3][1],grid[3][2],grid[3][3],grid[3][4],grid[3][5],grid[3][6],grid[3][7],grid[3][8]);
	displayTextLine(6,"%c,%c,%c,%c,%c,%c,%c,%c,%c",grid[2][0],grid[2][1],grid[2][2],grid[2][3],grid[2][4],grid[2][5],grid[2][6],grid[2][7],grid[2][8]);
	displayTextLine(7,"%c,%c,%c,%c,%c,%c,%c,%c,%c",grid[1][0],grid[1][1],grid[1][2],grid[1][3],grid[1][4],grid[1][5],grid[1][6],grid[1][7],grid[1][8]);
	displayTextLine(8,"%c,%c,%c,%c,%c,%c,%c,%c,%c",grid[0][0],grid[0][1],grid[0][2],grid[0][3],grid[0][4],grid[0][5],grid[0][6],grid[0][7],grid[0][8]);
	motor[motorB]=0;
	motor[motorC]=0;
	wait1Msec(1000);

	//write to file
	for(int h=0;h<7;h++)
	{
		for(int j=0;j<9;j++)
		{
				fileWriteChar(fileHandle,grid[h][j]);
		}
		fileWriteData(fileHandle,line1,line2);
	}
	fileClose(fileHandle);
}//end check array()
/**
 *	Checks for a file existence
 *
 *	\param char* nfile_check - char[] with filename to check
 *	\return TRUE - the file exists
 *	\return FALSE - The file doesn't exist
 */
BOOL SDFileCheck(char* nfile_check)
{	
	//	Open file; it must be specified the mode (now it is set to read only existing files)
	fRes = f_open(&fObj, nfile_check, FA_OPEN_EXISTING);
	
	//	Check error
	if (fRes != FR_OK)
	{
		if (fRes == FR_NOT_READY)
		{
			if (sdDetect())
				setSdErr(SD_NOT_READY);
			else
				setSdErr(SD_NOT_PRESENT);
		}
		else
			setSdErr(SD_GENERIC_ERROR);
		return FALSE;
	}
	else 
	{
		fileClose(&fObj);
		setSdErr(0);
		return TRUE;
	}
}
예제 #3
0
static void CommitPart(
	autoList_t *partFiles,
	char *wMode,
	void (*writeElement_x)(FILE *fp, uint element),
	sint (*compElement)(uint element1, uint element2),
	autoList_t *elements
	)
{
	rapidSort(elements, compElement);

	{
		char *partFile = makeTempPath("part");
		FILE *fp;
		uint element;
		uint index;

		addElement(partFiles, (uint)partFile);
		fp = fileOpen(partFile, wMode);

		foreach(elements, element, index)
			writeElement_x(fp, element);

		fileClose(fp);
		releaseAutoList(elements);
	}
}
예제 #4
0
static int writeFileConfig(const char *configName, const char *imageName)
{
	// Set the wallpaper in the requested config file.

	int status = 0;
	file f;

	memset(&f, 0, sizeof(file));

	status = fileFind(configName, NULL);
	if (status < 0)
	{
		// The file doesn't exist.  Try to create it.
		status = fileOpen(configName, (OPENMODE_WRITE | OPENMODE_CREATE), &f);
		if (status < 0)
			return (status);

		// Now close the file
		fileClose(&f);
	}

	// Save the wallpaper variable
	if (imageName)
		status = configSet(configName, "background.image", imageName);
	else
		status = configUnset(configName, "background.image");

	return (status);
}
예제 #5
0
int main(int argc, char **argv)
{
	char *sosuFile = makeTempFile("sosu");
	uint64 value;
	uint64 max = toValue64(nextArg());

	errorCase(max < 11);
	errorCase(max == UINT64MAX);

	SosuFp = fileOpen(sosuFile, "a+b");
	SosuCnt = 0;

	for(value = 11; value <= max; value += 2)
	{
		if((value & 0x3ffe) == 0)
			cmdTitle_x(xcout("Prime2tox - %I64u", value));

		if(
			value % 3 != 0 &&
			value % 5 != 0 &&
			value % 7 != 0 &&
			IsSosu(value)
			)
			AddSosu(value);
	}
	cmdTitle("Prime2tox - Completed");
	DispSosu();

	fileClose(SosuFp);
	removeFile(sosuFile);
	memFree(sosuFile);
}
예제 #6
0
bool TextEdit::qt_invoke( int _id, QUObject* _o )
{
    switch ( _id - staticMetaObject()->slotOffset() ) {
    case 0: fileNew(); break;
    case 1: fileOpen(); break;
    case 2: fileSave(); break;
    case 3: fileSaveAs(); break;
    case 4: filePrint(); break;
    case 5: fileClose(); break;
    case 6: fileExit(); break;
    case 7: editUndo(); break;
    case 8: editRedo(); break;
    case 9: editCut(); break;
    case 10: editCopy(); break;
    case 11: editPaste(); break;
    case 12: textBold(); break;
    case 13: textUnderline(); break;
    case 14: textItalic(); break;
    case 15: textFamily((const QString&)static_QUType_QString.get(_o+1)); break;
    case 16: textSize((const QString&)static_QUType_QString.get(_o+1)); break;
    case 17: textColor(); break;
    case 18: textAlign((QAction*)static_QUType_ptr.get(_o+1)); break;
    case 19: fontChanged((const QFont&)*((const QFont*)static_QUType_ptr.get(_o+1))); break;
    case 20: colorChanged((const QColor&)*((const QColor*)static_QUType_ptr.get(_o+1))); break;
    case 21: alignmentChanged((int)static_QUType_int.get(_o+1)); break;
    case 22: editorChanged((QWidget*)static_QUType_ptr.get(_o+1)); break;
    default:
	return QMainWindow::qt_invoke( _id, _o );
    }
    return TRUE;
}
예제 #7
0
unsigned long fileSize(FILE *stream, char *name)
{
    long    n   = 0;
    FILE    *f  = stream;
    
    if (!stream) {
        if (!name)
            return 0;
        
        f = fileOpen(name, "r");
        if (!f)
            return 0;
    }
    
    fileSeek(f, 0, SEEK_END);
    n = fileTell(f);
    
    if (!stream) {
        fileClose(f);
    } else {
        fileSeek(f, 0, SEEK_SET);
    }
    
    return n;
}
/**
 *	Provides file size (in bytes)
 *
 *	\param char* nfile_size - char[] with filename to check
 *	\return	DWORD >=0 - file size
 *	\return -1 - Operation failed
 */
DWORD SDFileSize(char *nfile_size)
{
	DWORD size = -1;
	//	Open file; it must be specified the mode (now it is set to read only existing files)
	fRes = f_open(&fObj, nfile_size, FA_OPEN_EXISTING);

	//	Check error
	if (fRes != FR_OK)
	{
		if (fRes == FR_NOT_READY)
		{
			if (sdDetect())
				setSdErr(SD_NOT_READY);
			else
				setSdErr(SD_NOT_PRESENT);
		}
		else
			setSdErr(SD_GENERIC_ERROR);
		return size;
	}
	else 
	{
		size = fObj.fsize;
		fileClose(&fObj);
		setSdErr(0);
		return size;
	}
}
예제 #9
0
int _rsSubStructFileClose(
    rsComm_t*                _comm,
    subStructFileFdOprInp_t* _close_inp ) {
    // =-=-=-=-=-=-=-
    // create first class structured object
    irods::structured_object_ptr struct_obj(
        new irods::structured_object( *_close_inp ) );
    struct_obj->comm( _comm );
    struct_obj->resc_hier( _close_inp->resc_hier );
    struct_obj->file_descriptor( _close_inp->fd );

    // =-=-=-=-=-=-=-
    // call abstrcated interface to open a file
    irods::error close_err = fileClose( _comm, struct_obj );
    if ( !close_err.ok() ) {
        std::stringstream msg;
        msg << "failed on call to fileClose for fd [ ";
        msg << struct_obj->file_descriptor();
        msg << " ]";
        irods::log( PASSMSG( msg.str(), close_err ) );
        return close_err.code();

    }
    else {
        return close_err.code();

    }

}
예제 #10
0
/**
 * osGetLoadAvg
 *
 */
IEC_UINT osGetLoadAvg(IEC_REAL *fp1, IEC_REAL *fp5, IEC_REAL *fp15, IEC_UDINT *ulpPReady, IEC_UDINT *ulpPSum)
{
	IEC_UINT uRes = OK;

  #if defined(RTS_CFG_LINUX)

	IEC_UDINT hFile = 0;
	IEC_CHAR  szBuff[2048];

	IEC_UDINT ulPLast;

	uRes = fileOpen(&hFile, FILE_LOADAVG, FIO_MODE_READ, TRUE);
	if (uRes != OK)
	{
		RETURN(uRes);
	}

	uRes = fileReadLine(hFile, szBuff, sizeof(szBuff));
	if (uRes != OK)
	{
		fileClose(hFile);
		RETURN(uRes);
	}

	uRes = fileClose(hFile);

	/* 1 min. load average | 5 min. load average | 15 min load average
	 * processes ready to run | overall number of processes | last PID
	 */
	
	uRes = (IEC_UINT)OS_SSCANF(szBuff, "%f %f %f %u/%u %u", fp1, fp5, fp15, ulpPReady, ulpPSum, &ulPLast);
	if (uRes != 6)
	{
		RETURN(ERR_INVALID_DATA);
	}

	uRes = OK;

  #else

	*fp1 = *fp5 = *fp15		= 0.0;
	*ulpPReady = *ulpPSum	= 0;

  #endif

	RETURN(uRes);
}
예제 #11
0
/* fileCloseAll: close all open files */
void fileCloseAll()
{
    int     i;

    for( i = 1; i <= FILE_MAX_HANDLE; i++ ) {
        fileClose( i );
    }
}
예제 #12
0
/**
 * Shell command () prints existing files or creates new ones.
 * @param args array of arguments
 * @return OK for success, SYSERR for syntax error
 */
command xsh_cat(int nargs, char *args[])
{
    int fd = 0;
    char c = 0;

    /* Output help, if '--help' argument was supplied */
    if ((nargs == 2 && strncmp(args[1], "--help", 6) == 0) || (nargs > 3) || (nargs < 2))
    {
        printf("Usage: cat [filename] or cat > [filename]\n");
        printf("Print file contents or copy console input into new file.\n");
        printf("\t--help\t display this help and exit\n");

        return OK;
    }
    if (nargs == 2)
    { /* Cat a file */
	fd = fileOpen(args[1]);
	if (SYSERR != fd)
	{
		fileSeek(fd, 0);
		while ((c = fileGetChar(fd)) != (char)SYSERR)
		{
			printf("%c", c);
		}
	}
	else
	{
		printf("File \"%s\" not found.\n", args[1]);
	}
	printf("\n\n");
	return OK;
    }
    if (strncmp(args[1], ">", 2))
    {
	    printf("ERROR: Cannot read from \"%s\", only CONSOLE!\n", args[1]);
	    return SYSERR;
    }
    if (SYSERR != fileOpen(args[2]))
    {
	    printf("ERROR: file \"%s\" already exists!\n", args[2]);
	    return SYSERR;
    }
    fd = fileCreate(args[2]);
    if (SYSERR == fd)
    {
	    printf("ERROR creating file \"%s\"\n", args[2]);
	    return SYSERR;
    }
    printf("Creating new file \"%s\".  Enter ~ to exit.\n", args[2]);
    while ((c = getc(CONSOLE)) != '~')
    {
	    filePutChar(fd, c);
    }
    fileClose(fd);

    return OK;
}
예제 #13
0
파일: file.cpp 프로젝트: kod3r/pyston
Box* fileExit(BoxedFile* self, Box* exc_type, Box* exc_val, Box** args) {
    Box* exc_tb = args[0];
    assert(self->cls == file_cls);
    assert(exc_type == None);
    assert(exc_val == None);
    assert(exc_tb == None);

    return fileClose(self);
}
예제 #14
0
uint32_t fileGetSize(const String fileName)
{
	file_t file = fileOpen(fileName.c_str(), eFO_ReadOnly);
	// Get size
	fileSeek(file, 0, eSO_FileEnd);
	int size = fileTell(file);
	fileClose(file);
	return size;
}
예제 #15
0
FileStream::~FileStream()
{
	fileClose(handle);
	handle = 0;
	pos = 0;
	if (buffer != NULL)
		delete[] buffer;
	buffer = NULL;
}
예제 #16
0
static void TextFltr(char *rFile, char *wFile)
{
	FILE *rfp = fileOpen(rFile, "rb");
	FILE *wfp = fileOpen(wFile, "wt");
	char *line;

	cout("TextFltr\n");
	cout("< %s\n", rFile);
	cout("> %s\n", wFile);

	while(line = readLine(rfp))
	{
		line2JLine(line, 1, 0, 1, 1);
		writeLine_x(wfp, line);
	}
	fileClose(rfp);
	fileClose(wfp);
}
예제 #17
0
void init_query_samples(char* input_filename, pars_t* pars)
{
    FILE* input = fileOpenR(input_filename);
    
    int field_index = 0;
    int sample_name_length = 0;
    pars->sample_name_max_length = 0;
    char c, c_prev;
    
    while((c = (char) getc(input)) != EOF)
    {
        if(c == '#')
        {
            c = (char) getc(input);
            if(c == '#')
            {
                while(c != '\n') c = (char) getc(input);
            }
            else
            {
                while(c != '\n')
                {
                    c_prev = c;
                    c = (char) getc(input);
                    if(c == '\n') break;
                    if((c_prev == ' ' || c_prev == '\t') && (c != ' ' && c != '\t'))
                    {
                        field_index++;
                        if(field_index > VCF_MANDATORY)
                        {
                            sample_name_length = 1;
                        }
                    }
                    else if((c_prev != ' ' || c_prev != '\t') && (c != ' ' && c != '\t'))
                    {
                        if(field_index > VCF_MANDATORY)
                        {
                            sample_name_length++;
                        }
                    }
                    else
                    {
                        if(field_index > VCF_MANDATORY && sample_name_length > pars->sample_name_max_length)
                        {
                            pars->sample_name_max_length = sample_name_length;
                        }
                    }
                }
                break;
            }
        }
    }
    
    pars->sample_num = field_index - VCF_MANDATORY;
    fileClose(input);
}
예제 #18
0
/**
 * osGetStat
 *
 */
IEC_UINT osGetStat(SProcTime *pPT)
{
	IEC_UINT uRes = OK;

  #if defined(RTS_CFG_LINUX)
	IEC_UDINT hFile = 0;
	IEC_CHAR  szBuff[2048];

	uRes = fileOpen(&hFile, FILE_STAT, FIO_MODE_READ, TRUE);
	if (uRes != OK)
	{
		RETURN(uRes);
	}

	uRes = fileReadLine(hFile, szBuff, sizeof(szBuff));
	if (uRes != OK)
	{
		fileClose(hFile);
		RETURN(uRes);
	}

	fileClose(hFile);
	
	/* User | Nice | System | Idle
	 * (in jiffies)
	 */

	uRes = (IEC_UINT)OS_SSCANF(szBuff, "cpu  %u %u %u %u", &pPT->ulUser, &pPT->ulNice, &pPT->ulSyst, &pPT->ulIdle);
	if (uRes != 4)
	{
		RETURN(ERR_INVALID_DATA);
	}

	uRes = OK;

  #else

	OS_MEMSET(pPT, 0x00, sizeof(SProcTime));

  #endif

	RETURN(uRes);
}
예제 #19
0
파일: scenpick.c 프로젝트: Almamu/homeworld
/*-----------------------------------------------------------------------------
    Name        : spTitleFind
    Description : Finds the title of a mission file (on first line, in brackets)
    Inputs      : directory, fileName - combine to form path to the file.
    Outputs     : Allocated memory for and duplicates a string.
    Return      : Pointer to title string.
----------------------------------------------------------------------------*/
char *spTitleFind(char *directory, char *fileName)
{
    char string[256], fullName[_MAX_PATH];
    filehandle handle;
    sdword status;

    memStrncpy(fullName, directory, _MAX_PATH - 1);
    strcat(fullName, fileName);
    strcat(fullName,"\\");
    strcat(fullName, fileName);
    strcat(fullName,".level");
    handle = fileOpen(fullName, FF_TextMode|FF_ReturnNULLOnFail);
    if (!handle)
    {
        return NULL;
    }

    for (;;)
    {
        status = fileLineRead(handle,string,256);

        if (status == FR_EndOfFile)
        {
            break;
        }

        if ((string[0] == '\n') || (string[0] == '/') || (string[0] == ';') || (string[0] == ' '))
        {
            continue;
        }

        if (strlen(string) >= 3 && *string == '[' && string[strlen(string) - 1] == ']')
        {
            fileClose(handle);
            string[strlen(string) - 1] = 0;
            return(memStringDupe(&string[1]));
        }
    }

    fileClose(handle);

    return memStringDupe(fullName);
}
예제 #20
0
main()
{
 int screenInput=CONSOLE_INPUT;
 int numberOfTasks=0;
 int count=0;
 float density=0;
 float utilization=0;
 int hyperperiod=0;
 FILE* fp;

 if(screenInput)
 {
	 printf("Enter Number of Tasks: ");
	 scanf("%d",&numberOfTasks);
	 while (count < numberOfTasks)
	 {
		 	 printf("Enter Release Time of Task %d: ", count);
		 	 scanf("%d",&taskInfo[count][0]);
		 	 printf("Enter Period of Task %d: ", count);
		 	 scanf("%d",&taskInfo[count][1]);
		 	 printf("Enter Execution Time of Task %d: ", count);
		 	 scanf("%d",&taskInfo[count][2]);
		 	 printf("Enter Deadline of Task %d: ", count);
		 	 scanf("%d",&taskInfo[count][3]);
	 		 count++;
	 }
 }
 else
 {
	 fp=fileOpen();
	 numberOfTasks=fReadNumOfTasks(fp);
	 printf("Number of Tasks: %d\n",numberOfTasks);
	 fReadTaskDetails(fp, numberOfTasks);
	 while (count < numberOfTasks)
	 {
		 printf("%d %d %d %d\n",taskInfo[count][0], taskInfo[count][1], taskInfo[count][2], taskInfo[count][3]);
		 count++;
	 }
	 fileClose(fp);
 }
 density=calculateDensity(numberOfTasks);
 printf("Density: %f\n",density);
 utilization=calculateCpuUtilization(numberOfTasks);
 printf("Utilization: %f\n",utilization);
 if (density > 1)
 {
	 printf("Density for the task set is more than 1. Schedule cannot be created.");
 }
 else
 {
	 hyperperiod=calculateHyperPeriod(numberOfTasks);
	 printf("Hyperperiod: %d\n",hyperperiod);
	 calculateLLF(numberOfTasks, hyperperiod);
 }
}
예제 #21
0
void Sound::playVoice(int16_t objKey, uint32_t crc) {
	char name[16];
	snprintf(name, sizeof(name), "%08X.WAV", crc);
	int dataSize;
	FILE *fp = fileOpen(name, &dataSize, kFileType_VOICE, false);
	debug(kDebug_SOUND, "Sound::playVoice() '%s' dataSize %d", name, dataSize);
	if (fp) {
		_mix.playWav(fp, dataSize, kDefaultVolume, kDefaultPan, makeId(objKey));
		fileClose(fp);
	}
}
예제 #22
0
String fileGetContent(const String fileName)
{
	file_t file = fileOpen(fileName.c_str(), eFO_ReadOnly);
	// Get size
	fileSeek(file, 0, eSO_FileEnd);
	int size = fileTell(file);
	if (size <= 0)
	{
		fileClose(file);
		return "";
	}
	fileSeek(file, 0, eSO_FileStart);
	char* buffer = new char[size + 1];
	buffer[size] = 0;
	fileRead(file, buffer, size);
	fileClose(file);
	String res = buffer;
	delete[] buffer;
	return res;
}
예제 #23
0
int fileGetContent(const String fileName, char* buffer, int bufSize)
{
	if (buffer == NULL || bufSize == 0) return 0;
	*buffer = 0;

	file_t file = fileOpen(fileName.c_str(), eFO_ReadOnly);
	// Get size
	fileSeek(file, 0, eSO_FileEnd);
	int size = fileTell(file);
	if (size <= 0 || bufSize <= size)
	{
		fileClose(file);
		return 0;
	}
	buffer[size] = 0;
	fileSeek(file, 0, eSO_FileStart);
	fileRead(file, buffer, size);
	fileClose(file);
	return size;
}
/**
 *	Appends data on a file on current directory
 *
 *	\param char* nfile_append - char[] with filename to create
 *	\param char* buff_to_app - char[] with data to write
 *	\param unsigned int to_write - number of chars to write
 *	\return TRUE - operation success
 *	\return FALSE - operation failed
 */
BOOL SDFileAppend(char *nfile_append, char *buff_to_app, unsigned int to_write)
{
#if _FS_READONLY
	return FALSE;
#else
	unsigned int len;
	if (fObj.flag == 0)
	{
		//	File opening
		fRes = f_open(&fObj, nfile_append, FA_OPEN_EXISTING|FA_WRITE);
		if (fRes != FR_OK)
		{
			errManager();
			return FALSE;
		}	
		
		//	Seek to the end of file
		fRes = f_lseek(&fObj, f_size(&fObj));
		if (fRes != FR_OK)
		{
			errManager();
			fileClose(&fObj);
			return FALSE;		
		}
		
		//	Append of the text at the end of file
		fRes = f_write(&fObj, buff_to_app, to_write, &len);
		if ( (fRes != FR_OK) || (len != to_write) )
		{
			SDdebug("ERROR on write\n");
			errManager();
			fileClose(&fObj);
			return FALSE;
		}
		fileClose(&fObj);
		return TRUE;
	}
	else
		return FALSE;
#endif
}
예제 #25
0
void ClintWindow::fileOpen() {
  QString selectedFilter;
  QString fileName = QFileDialog::getOpenFileName(this, "Open file", QString(), "OpenScop files (*.scop);;C/C++ sources (*.c *.cpp *.cxx)", &selectedFilter);
  if (fileName.isNull())
    return;

  if (m_fileOpen) {
    fileClose();
  }

  openFileByName(fileName);
}
예제 #26
0
void MainWindow::createActions() {
    _fileNewAct = new QAction(tr("&New..."), this);
    _fileNewAct->setShortcut(QKeySequence::New);
    _fileNewAct->setStatusTip(tr("Create new simulation"));
    _fileNewAct->setIcon(QIcon::fromTheme("document-new", QIcon(":/icons/new.png")));
    connect(_fileNewAct, SIGNAL(triggered()), this, SLOT(fileNew()));


    _fileOpenAct = new QAction(tr("&Open..."), this);
    _fileOpenAct->setShortcut(QKeySequence::Open);
    _fileOpenAct->setStatusTip(tr("Load existing simulation data"));
    _fileOpenAct->setIcon(QIcon::fromTheme("document-open", QIcon(":/icons/open.png")));
    connect(_fileOpenAct, SIGNAL(triggered()), this, SLOT(fileOpen()));

    _fileCloseAct = new QAction(tr("&Close..."), this);
    _fileCloseAct->setShortcut(QKeySequence::Close);
    _fileCloseAct->setStatusTip(tr("Exit current simulation"));
    connect(_fileCloseAct, SIGNAL(triggered()), this, SLOT(fileClose()));

    _fileSaveAct = new QAction(tr("&Save"), this);
    _fileSaveAct->setShortcut(QKeySequence::Save);
    _fileSaveAct->setStatusTip(tr("Save simulation data to file"));
    _fileSaveAct->setIcon(QIcon::fromTheme("document-save", QIcon(":/icons/save.png")));
    connect(_fileSaveAct, SIGNAL(triggered()), this, SLOT(fileSave()));

    _fileSaveAsAct = new QAction(tr("Save &as..."), this);
    _fileSaveAsAct->setShortcut(QKeySequence::SaveAs);
    _fileSaveAsAct->setStatusTip(tr("Save simulation data to file"));
    _fileSaveAsAct->setIcon(QIcon::fromTheme("document-save-as", QIcon(":/icons/save.png")));
    connect(_fileSaveAsAct, SIGNAL(triggered()), this, SLOT(fileSaveAs()));

    _fileExitAct = new QAction(tr("E&xit..."), this);
    _fileExitAct->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_X));
    _fileExitAct->setStatusTip(tr("Exit program"));
    _fileExitAct->setIcon(QIcon::fromTheme("application-exit"));
    connect(_fileExitAct, SIGNAL(triggered()), this, SLOT(close()));


    _helpAboutAct = new QAction(tr("&About"), this);
    _helpAboutAct->setStatusTip(tr("About HPC program"));
    _helpAboutAct->setIcon(QIcon::fromTheme("help-about"));
    connect(_helpAboutAct, SIGNAL(triggered()), this, SLOT(helpAbout()));

    _helpAboutQtAct = new QAction(tr("&About Qt"), this);
    _helpAboutQtAct->setStatusTip(tr("About Qt framework"));
    _helpAboutQtAct->setIcon(QIcon::fromTheme("help-about"));
    connect(_helpAboutQtAct, SIGNAL(triggered()), this, SLOT(helpAboutQt()));

    _fileSaveAct->setEnabled(false);
    _fileSaveAsAct->setEnabled(false);
    _fileCloseAct->setEnabled(false);
}
예제 #27
0
int
_rsFileGet (rsComm_t *rsComm, fileOpenInp_t *fileGetInp, 
bytesBuf_t *fileGetOutBBuf)
{
    int status;
    int fd;
    int len;

    len = fileGetInp->dataSize;
    if (len <= 0)
	return (0);

    fd = _rsFileOpen (rsComm, fileGetInp);

    if (fd < 0) {
        rodsLog (LOG_NOTICE,
          "_rsFileGet: fileGet for %s, status = %d",
          fileGetInp->fileName, fd);
        return (fd);
    }

    if (fileGetOutBBuf->buf == NULL) {
        fileGetOutBBuf->buf = malloc (len);
    }
    status = fileRead (fileGetInp->fileType, rsComm,
      fd, fileGetOutBBuf->buf, len);

    if (status != len) {
       if (status >= 0) {
#if 0	/* XXXXXXXX take this out for now so that on the fly convert works */
            rodsLog (LOG_NOTICE,
              "_rsFileGet: fileRead for %s, toread %d, read %d",
              fileGetInp->fileName, len, status);
            status = SYS_COPY_LEN_ERR;
#else
        fileGetOutBBuf->len = status;
#endif
        } else {
            rodsLog (LOG_NOTICE,
              "_rsFileGet: fileRead for %s, status = %d",
              fileGetInp->fileName, status);
        }
    } else {
        fileGetOutBBuf->len = status;
    }

    fileClose (fileGetInp->fileType, rsComm, fd);

    return (status);
} 
/**
 * Reads data form a file starting form a position
 *
 *	\param char* nfile_read - name of file to be read
 *	\param char* destBuff - buffer to fill with data read
 *	\param unsigned long to_read - amount of data to read from file
 *	\param unsigned long start - starting position (absolute position from, 0 is first data of file)
 *	\return WORD - amount of data read
 */
WORD SDFileReadAt(char* nfile_read, char* destBuff, unsigned long to_read, unsigned long start)
{
	unsigned int len;
	if (fObj.flag == 0)
	{
		//	File opening
		fRes = f_open(&fObj, nfile_read, FA_OPEN_EXISTING|FA_READ);
		if (fRes != FR_OK)
		{
			errManager();
			return 0;
		}
		
		//	Seek to the end of file
		fRes = f_lseek(&fObj, start);
		if (fRes != FR_OK)
		{
			errManager();
			fileClose(&fObj);
			return 0;		
		}
		
		//	Read text from file
		fRes = f_read(&fObj, destBuff, to_read, &len);
		if ( (fRes != FR_OK) || (len != to_read) )
		{
			SDdebug("ERROR on SDFileReadAt\n");
			errManager();
			fileClose(&fObj);
			return len;
		}
		fileClose(&fObj);
		return len;
	}
	else
		return 0;
}
예제 #29
0
static void GetCryptoSeed(uchar *seed, uint seed_size, char *seed_file)
{
	if(isFactoryDirEnabled())
	{
		autoBlock_t gab;

		mutex();

		// zantei >

		if(existFile(seed_file) && getFileSize(seed_file) != (uint64)seed_size)
		{
			cout("#########################################################\n");
			cout("## SEED_FILE SIZE ERROR -- どっかに古い exe があるで! ##\n");
			cout("#########################################################\n");

			removeFile(seed_file);
		}

		// < zantei

		if(existFile(seed_file))
		{
			FILE *fp;
			uint index;

			fp = fileOpen(seed_file, "rb");
			fileRead(fp, gndBlockVar(seed, seed_size, gab));
			fileClose(fp);

			for(index = 0; index < seed_size; index++)
			{
				if(seed[index] < 0xff)
				{
					seed[index]++;
					break;
				}
				seed[index] = 0x00;
			}
		}
		else
			getCryptoBlock_MS(seed, seed_size);

		writeBinary(seed_file, gndBlockVar(seed, seed_size, gab));
		unmutex();
	}
	else
		getCryptoBlock_MS(seed, seed_size);
}
예제 #30
0
void HttpClient::onFinished(TcpClientState finishState)
{
	if (finishState == eTCS_Failed) code = 0;

	if (mode == eHCM_File)
	{
		debugf("Download file len written: %d, res^ %d", fileTell(saveFile), isSuccessful());
		if (!isSuccessful())
			fileDelete(saveFile);
		fileClose(saveFile);
	}

	if (onCompleted)
		onCompleted(*this, isSuccessful());

	TcpClient::onFinished(finishState);
}