void MessageStorage::freeMessageEntry(MessageEntry * entry)
{
	// check entry validity
	if((entry->memPtr == NULL && entry->fileName == NULL) ||
	   (entry->memPtr != NULL && entry->fileName != NULL))
	{
		module_debug_strg("freeMessageEntry: invalid entry!");
		return;
	}
	
	// first free the memory buffers for the entry
	if(entry->memPtr != NULL)
	{
		free(entry->memPtr);
		entry->memPtr = NULL;
	}
	
	// delete stored file if exists
	if(entry->fileName != 0)
	{
		char fnBuffer[13];
		changeDirectory(SUBDIR_QUEUE);
		sprintf(fnBuffer, "%d", entry->fileName);
		deleteFile(fnBuffer);
		changeDirectory("..");
	}
	
	// finally, deallocate the MessageEntry space itself
	free(entry);
}
Ejemplo n.º 2
0
void handleCommandCd(char* args[], int numargs) {
  if (numargs == 0)
  {
    changeDirectory("");
  } else
  {
    //As in shell: if there are more than 1 argument, command won't return any warning
    //and interpret only this first argument
    changeDirectory(args[0]);
  }
}
Ejemplo n.º 3
0
void entry()
{
  int errors = 0;
  xBase::logExceptions = false;
  //nonportFail = xSysError::xsyserror;

  //TRY_FAIL(createDirectory("/tmp\\Scott\\"),
  //         R_ALREADY_EXISTS);

  TRY_FAIL(changeDirectory("some.strange.name/yadda"),
           R_PATH_NOT_FOUND);

  TRY_FAIL(createDirectory("/tmp"),
           R_ALREADY_EXISTS);

  TRY_FAIL(isDirectory("doesnt.exist"),
           R_FILE_NOT_FOUND);

  if (errors == 0) {
    std::cout << "success!\n";
  }
  else {
    std::cout << errors << " error(s)\n";
  }
}
Ejemplo n.º 4
0
void SidePanel::start_pause_resume() {
    // Check that the saving directory was set if asked to save data
    if (saveDirCheckBox->isChecked() && m_saveDirectory == "") {
        const QString message = "Please choose a saving directory before starting the simulation.";
        QMessageBox msgBox(QMessageBox::Warning, "No saving directory chosen !", message, 0, this);
        msgBox.addButton("Choose saving directory", QMessageBox::AcceptRole);
        msgBox.addButton("Cancel", QMessageBox::RejectRole);
        if (msgBox.exec() == QMessageBox::AcceptRole) {
            changeDirectory();
        }
        return;
    }

    setModelOptionsStatus(false);
    stopButton->setEnabled(true);
    m_paused = !m_paused;
    if (m_paused) {
        emit pauseOrResumePushed(true);
        startButton->setText("Resume");
    } else {
        if (startButton->text() != "Start") {
            emit pauseOrResumePushed(false);
        } else {
            emit startPushed();
        }
        startButton->setText("Pause");
    }
}
Ejemplo n.º 5
0
void catFile(char *path)
{
	char parameter[20][20], *ptr = NULL;
	int cnt, j, i = 0;
	int inodeNumber;

	ptr = strtok(path, "/");
	while (ptr) {
		strcpy(parameter[i++], ptr);
		ptr = strtok(NULL, "/");
	}
	i--;
	cnt = i;
	j = 0;
	while (i > 0) {
		int st = changeDirectory(parameter[j++]);
		i--;
		if (st == -1)
			printf("\n No such directory found %s ", parameter[j - 1]);
	}

	if (i == 0)
		inodeNumber = getInodeNumberFromDirectory(parameter[j]);
	else
		inodeNumber = getInodeNumberFromDirectory(parameter[cnt - 1]);

	if (inodeNumber == -1) {
		printf("\n\tInvalid file name specified\n");
		return;
	}
	printf("\n\n%s\n\n", DILB[inodeNumber].data);
	return;
}
Ejemplo n.º 6
0
Dock::Dock()
{
    av_register_all();

    flow_ = new PictureFlow;
    flow_->resize( g_configuration->getTotalWidth()/8,
                   g_configuration->getTotalHeight()/8 );
    const int height = flow_->height() * .8;
    flow_->setSlideSize( QSize( 0.6 * height, height ));
    flow_->setBackgroundColor( Qt::darkGray );

    streamer_ = new ImageStreamer;
    streamer_->moveToThread( &streamThread_ );
    connect( flow_, SIGNAL( imageUpdated( const QImage& )),
             streamer_, SLOT( send( const QImage& )));
    connect( &streamThread_, SIGNAL(finished()), streamer_, SLOT(disconnect( )));
    connect( this, SIGNAL(started()), streamer_, SLOT(connect( )));
    connect( this, SIGNAL(finished()), streamer_, SLOT(disconnect( )));
    streamThread_.start();

    loader_ = new ImageLoader( flow_ );
    loader_->moveToThread( &loadThread_ );
    connect( this, SIGNAL(renderPreview( const QString&, const int )),
             loader_, SLOT(loadImage( const QString&, const int )));
    loadThread_.start();

    changeDirectory( g_configuration->getDockStartDir( ));
}
Ejemplo n.º 7
0
void listDirectory(Node *root, char* path)
{
	Node *node;
	List *iterator;

	node = changeDirectory(root,path);
	if(node == NULL)
	{
		printf("ERROR: No such file or Directory.\n");
		return;
	}
	printf("%s: \n",path);
	iterator = node->listDir;
	while(iterator != NULL)
	{
		printf("  %s\n", iterator->node->name);
		iterator = iterator->next;	
	}
	
	iterator = node->listFile;
	while(iterator != NULL)
	{
		printf("  %s\n", iterator->node->name);
		iterator = iterator->next;	
	}
}
Ejemplo n.º 8
0
void Dock::onItem()
{
    const QImage& image = flow_->slide( flow_->centerIndex( ));
    const QString& source = image.text( "source" );

    if( !image.text( "dir" ).isEmpty( ))
    {
        changeDirectory( source );
        return;
    }

    const QString extension = QFileInfo(source).suffix().toLower();
    if( extension == "dcx" )
    {
        g_displayGroupManager->loadStateXMLFile( source.toStdString( ));
        return;
    }

    boost::shared_ptr< Content > c = ContentFactory::getContent( source );
    if( c )
    {
        boost::shared_ptr<ContentWindowManager> cwm(new ContentWindowManager(c));
        g_displayGroupManager->addContentWindowManager( cwm );
        cwm->adjustSize( SIZE_1TO1 );
    }
    QtConcurrent::run( closeDock, this );
}
Ejemplo n.º 9
0
int main(){
	int programStatus = RUNNING; /*Används för att kolla om kommandotolken ska fortsätta köra*/
	printf("\n\n*** Välkommen till vår egna kommandotolk ***\n******* För att avlsuta skriv 'exit' *******\n");
	char input[MAXINPUT];
	regSigHandler(SIGINT); /*Blockerar CTRL-C*/

	/**************** Kommandotolksloopen ********************/
	while(programStatus){
		char **arguments = (char **) calloc (MAXARG,  MAXINPUT);
	  	int length = 0;
	  	char *args;

		prompt(); /*Skriver ut vår kommandutolk*/

	  	/*Hämta in det som användaren skriver. Därefter delas den upp i de olika argument som skickats med*/
		fgets(input, MAXINPUT, stdin);
	    args = strtok(input, " \n\n");
	    while( args != NULL){
	      arguments[length] = args; 
	      args = strtok(NULL, " ");
	      length++;
	    }

	    cleanBgProcess(); /*Kolla om det finns avslutade bakgrundsprocesser*/
	    /*Gör ingenting om det inte finns några argument;*/
	    if (NULL == arguments[0]){
	    	
	    }
	    /*Man får inte bara skicka ett &*/
	    else if (strcmp(arguments[0], "&") == 0){
	    	printf("Du får inte bara skicka ett &...");
	    }
	    /*Hanterar att man ska stänga ner kommandotolk. Ändrar programStatus till CLOSING*/
	    else if (strcmp(arguments[0], "exit") == 0){
	    	printf("Stänger ner kommandotolken..\n");
	    	programStatus = CLOSING;
	    }
	    /*Kollar om man skrivit cd och skickar då vidare den till den funktionen*/
	    else if (strcmp(arguments[0], "cd") == 0){
            changeDirectory(arguments[1]);
	    }
	    /*Hanterar övriga kommandon*/
	    else{
	    	bool bgProcess = checkProcessType(arguments[length-1]);/*Kollar om det ska vara bakgrundsprocess*/
	    	if (bgProcess){
	    		/*Plockar bort &-tecknet eftersom det inte ska användas mer*/
	    		if (strcmp(arguments[length-1], "&") == 0){
	    			arguments[length-1] = NULL;
	    		}
	    		else{
	    			strtok(arguments[length-1], "&");
	    		}
	    	}
	    	/*Kör kommandot i funktionen executeCommand*/
	    	executeCommand(bgProcess, arguments);
	    }
	    free(arguments); /*Släpper argumenten i minnet*/
	}
}
void MessageStorage::endAudioSample()
{
	closeFile();
	changeDirectory("..");
	m_nextAudioSeqNumber++;
	
	module_debug_strg("next audio seqnr is %d", m_nextAudioSeqNumber);
}				   
bool DockPixelStreamer::setRootDir(const QString& dir)
{
    if ( !QDir(dir).exists( ))
        return false;

    rootDir_ = dir;
    changeDirectory(dir);
    return true;
}
Ejemplo n.º 12
0
int main(int args, char *argv[]){
  /*
   * Runs changeDirectory if there is an argument, otherwise it does nothing
   */
  if(args > 0){
    changeDirectory(argv[0]);
  }
  return 0;
}
Ejemplo n.º 13
0
int main(int argc, char *argv[])
{
    if (argc != 3)
    {
        fprintf(stderr, "Usage: test (folder you want to cd into) (folder you want to create)\n");
        return -1;
    }

    //Test if external command can execute
    struct command_t extCommand;

    extCommand.name = "cd";
    extCommand.argv[1] = "./";

    printf("isExternalCommand: %d\n", isExternalCommand(&extCommand));

    extCommand.name = "pwd";

    printf("isExternalCommand: %d\n", isExternalCommand(&extCommand));

    extCommand.name = "echo";
    extCommand.argv[1] = "Hello World";

    printf("isExternalCommand: %d\n", isExternalCommand(&extCommand));

    extCommand.name = "mkdir";
    extCommand.argv[1] = "temp";

    printf("isExternalCommand: %d\n", isExternalCommand(&extCommand));

    //Testing echo
    echoString("$PATH");

    //Testing printWorkingDirectory
    printWorkingDirectory();

    //Prompt should be set up properly
    printPrompt();

    //Test changing directory
    changeDirectory(argv[1]);

    //Testing printWorkingDirectory
    printWorkingDirectory();

    //Check that prompt updated its directory portion
    printPrompt();

    //To check if mkdir makes a directory in the new working directory
    int ret;
    char *cmd[] = { "mkdir", argv[2], (char *)0 };

    ret = execv("/bin/mkdir", cmd);

    return 0;
}
void MessageStorage::startAudioSample()
{
	char fnBuffer[13];
	sprintf(fnBuffer, "%d", m_nextAudioSeqNumber);
	
	module_debug_strg("creating %s under %s..", fnBuffer, SUBDIR_AUDIO);
	
	// create new file and write data
	changeDirectory(SUBDIR_AUDIO);
	openFile(fnBuffer, true, false);		
}
char * MessageStorage::getFromStorageQueueRaw(unsigned short * size)
{
	module_debug_strg("getFromStorageQueueRaw");
	// dequeue and deserialize message
	MessageEntry * headEntry = dequeue();
	
	if(!headEntry)
	{
		module_debug_strg("nothing to get from queue!");
		return NULL;
	}
	
	char * entryContent = (char *) headEntry->memPtr;	// NULL if file (handled below)
	
	// process serialized data depending on storage mode
	if(headEntry->fileName)
	{
		module_debug_strg("reading from file: %d", headEntry->fileName);
		// open file and read contained data
		char fnBuffer[13];
		entryContent = (char *) malloc(headEntry->size);
		sprintf(fnBuffer, "%d", headEntry->fileName);
		changeDirectory(SUBDIR_QUEUE);
		openFile(fnBuffer, false, true);
		readFromFile(entryContent, headEntry->size);
		closeFile();
		changeDirectory("..");
	}
	
	// make room for the deserialized data
	char * out_msg = (char*) malloc(headEntry->size);
	
	*size = headEntry->size;
	
	memcpy(out_msg, entryContent, headEntry->size);
	
	// free the resources used by the entry
	freeMessageEntry(headEntry);
	
	return out_msg;	
}
void MessageStorage::flushEntryToDisk(MessageEntry * entry)
{
	// check if this is a valid mem entry
	if(!entry)
		return;
	
	if(entry->memPtr == NULL || entry->fileName != NULL)
	{
		module_debug_strg("cannot flush non-mem entry!");
		return;
	}
	
	module_debug_strg("flushing...");
	
	// move mem entry to disk and free the occupied mem
	// file name will be the current Unix time
	entry->fileName = m_nextMessageSeqNumber++;
	
	char fnBuffer[13];
	sprintf(fnBuffer, "%d", entry->fileName);
	
	// TODO handle msg seq nr overflow
	
	module_debug_strg("flush to disk: %s", fnBuffer);
	
	// create new file and write data
	changeDirectory(SUBDIR_QUEUE);
	openFile(fnBuffer, true, false);
	writeToFile((char*) entry->memPtr, entry->size);
	closeFile();
	changeDirectory("..");
	
	// free occupied entry memory and set memPtr to NULL
	free(entry->memPtr);
	
		
	entry->memPtr = NULL;
	
	m_queueCountMem--;
	
}
Ejemplo n.º 17
0
void MVFileDialog::handleEvent(MVEvent& event,phaseType phase)
/****************************************************************************
*
* Function:		MVFileDialog::handleEvent
* Parameters:	event	- Event to handle
*				phase	- Current phase for the event (pre,focus,post)
*
* Description:	Event handling routine for the MVFileDialog class. Attempts
*				to end the modal operation if the open or save buttons
*				are hit.
*
****************************************************************************/
{
	MVDialog::handleEvent(event,phase);

	switch (event.what) {
		case evCommand:
			switch (event.message.command) {
				case cmFileOpen:
				case cmFileSave:
					endModal(event.message.command);
					clearEvent(event);
					break;
				case cmHelp:
					MV_messageBox(dc,"Help not implemented yet",
						mfInformation | mfOKButton | mfOKDefault);
					clearEvent(event);
					break;
				}
			break;
		case evBroadcast:
			switch (event.message.command) {
				case cmListCursorChanged:
					if (event.message.infoPtr == fileList) {
						updateFileLine();
						clearEvent(event);
						}
					break;
				case cmListItemSelected:
					if (event.message.infoPtr == fileList) {
						endModal((flags & fdOpenButton) ?
							cmFileOpen : cmFileSave);
						clearEvent(event);
						}
					else if (event.message.infoPtr == directoryList) {
						changeDirectory();
						clearEvent(event);
						}
					break;
				}
			break;
		}
}
Ejemplo n.º 18
0
int openFile(char *path, char *mode)
{
	char parameter[20][20], *ptr = NULL;
	int i = 0, cnt, j;
	int FTAdd, inodeNumber, fd;

	ptr = strtok(path, "/");
	while (ptr) {
		strcpy(parameter[i++], ptr);
		ptr = strtok(NULL, "/");
	}
	i--;
	cnt = i;
	j = 0;
	while (i > 0) {
		int st = changeDirectory(parameter[j++]);
		i--;
		if (st == -1)
			printf("\n No such directory found %s ", parameter[j - 1]);
	}

	if (i == 0)
		inodeNumber = getInodeNumberFromDirectory(parameter[j]);
	else
		inodeNumber = getInodeNumberFromDirectory(parameter[cnt - 1]);

	if (inodeNumber == -1) {
		printf("\n\tInvalid file name specified\n");
		return -1;
	}
	inodeNumber = checkInodeInFT(inodeNumber);
	if (inodeNumber == -1) {
		printf("\n\tFile is already opened..!!\n");
		return -1;
	}
	if (*mode == 'R')
		FTAdd = makeEntryInFT(inodeNumber, R);
	else if (*mode == 'W')
		FTAdd = makeEntryInFT(inodeNumber, W);
	else if (*mode == 'A')
		FTAdd = makeEntryInFT(inodeNumber, A);
	else {
		printf ("\n\tInvalid mode specified..!! Type \"help\" for help.\n");
		return -1;
	}
	FT[FTAdd].inode_number = inodeNumber;
	if (isUFDTFull()) {
		printf("\nSorry no free space is available\n");
		return -1;
	}
	fd = putFTAddIntoUFDT(FTAdd);
	return fd;
}
Ejemplo n.º 19
0
Archivo: xssh.c Proyecto: luok/XSSH
int run_cmd(int argc, char *argv[]) 
{	
	char last_bg_pid[50], msg[50];
	
	if (argv[0] == NULL) {
		/* ignore the blank line. */
		return 1;
    } else if (strcmp(argv[0], "quit") == 0) { 
		/* quit the shell. */
        if (argv[1] != NULL) {
			if (!isalpha(*argv[1])){ 
				cmd_exit_status = atoi(argv[1]);
			} 
		}
		
		exit_status = cmd_exit_status;
		return 0;
    } else if (strcmp(argv[0], "echo") == 0) { 
		/* echo: print all the words after the echo command. */
        cmd_exit_status = echo(argc, argv);
       
    } else if ((strcmp(argv[0], "cd") == 0) || (strcmp(argv[0], "chdir") == 0)) {
	 	/* change the working directory.*/
		
		cmd_exit_status = changeDirectory(argc, argv);

	} else if (strcmp(argv[0], "set") == 0) {
        
        /* Set variable by the given value.*/
        cmd_exit_status = setVariable(argc, argv);
    } else if (strcmp(argv[0], "wait") == 0) { 
		if (argv[1] == NULL) {
			printf("wait <PID>\n");
			cmd_exit_status = 1;
		} else {
        	cmd_exit_status = wait_cmd((pid_t) atoi(argv[1]));
		}
	} else if (strcmp(argv[0], "unset") == 0) { 
		/* do unset */
		cmd_exit_status = unset_cmd(argc, argv);
	} else {
		/* Command not found. Look for external command to run. */
		cmd_exit_status = run_external_cmd(argv);
	}
	
	sprintf(msg, "Command exited with exit status %d", cmd_exit_status);
	debug(msg);
	
	sprintf(last_bg_pid, "%d", background_pid);
	setenv("!", last_bg_pid, 1); 
	
	return 1;
}
Ejemplo n.º 20
0
//------------------------------------------------------------------------------
StatusCode 
RootHistCnv::DirectoryCnv::createRep(DataObject* pObj, IOpaqueAddress*& refpAddr) {
  if ( changeDirectory(pObj) ) {
    const char* d_nam = pObj->name().c_str()+1;
    if (! gDirectory->GetKey(d_nam) ) { 
      gDirectory->mkdir(d_nam); 
    }
    gDirectory->cd(d_nam);
    return createAddress(pObj, gDirectory, 0, refpAddr);
  }
  refpAddr = 0;
  return StatusCode::FAILURE;
}
Ejemplo n.º 21
0
void nodeDock::added()
{
    connect( app(), SIGNAL(entityAdded(AEntity*)), this, SLOT(centreNode(AEntity*)) );
    connect( app(), SIGNAL(entityRemoved(AEntity*)), this, SLOT(removeNode(AEntity*)) );
    connect( app(), SIGNAL(entityRemoved(AEntity*)), this, SLOT(entityRemoved(AEntity*)) );

    connect( app(), SIGNAL(selectionChanged()), this, SLOT(appSelectionChanged()) );
    connect( app(), SIGNAL(insertState()), this, SLOT(rebuildGui()) );
    connect( app(), SIGNAL(cleanState()), this, SLOT(rebuildGui()) );
    connect( app(), SIGNAL(openState()), this, SLOT(rebuildGui()) );
    connect( app(), SIGNAL(workingPathChanged()), this, SLOT(rebuildGui()) );

    mView->setApp(app());

    mScene->addItem( new propertiesWidget( app(), mView ) );

    qRegisterMetaType<AEntityLocation>();

    directoryListing *dir( new directoryListing( app(), mView ) );
    mScene->addItem( dir );
    connect( dir, SIGNAL(changeDirectory(AEntityLocation)), this, SLOT(changeDirectory(AEntityLocation)), Qt::QueuedConnection );
}
Ejemplo n.º 22
0
Node *removeFile(Node *root, char *absName)
{
	char *path = malloc(255),
		 *name = malloc(255);
	Node *node;
	List *list, 
		 *lastNode;	

	split(absName, path, name);
	node = changeDirectory(root,path);
	if (node == NULL) return root;

	int type;
	list = node->listDir;
	for(type = 0 ; type <2 ; type++)
	{
		int i = 1;
		lastNode=NULL;
		while(list!=NULL)
		{
			if(strcmp(list->node->name, name) == 0) 
			{
				if (type || !list->node->nFile)
				{
					if (lastNode == NULL)
						if (type)
						{ 
							node->listFile = node->listFile->next;
						}
						else
						{
						    node->listDir  = node->listDir->next;
						}
					else
						lastNode->next = list->next;

					free(list->node);
					free(list);
					node->nFile--;
				}
				else printf("ERROR: Directory is not empty.\n");
				return root;
			}
			lastNode = list;
			list     = list->next;
		}
		list = node->listFile;
	}
	printf("ERROR: No such file or directory.\n");
	return root;
}
Ejemplo n.º 23
0
/****** Interactive/qrsh/--qrsh_starter ***************************************
*
*  NAME
*     qrsh_starter -- start a command special correct environment
*
*  SYNOPSIS
*     qrsh_starter <environment file> <noshell>
*     int main(int argc, char **argv[])
*
*  FUNCTION
*     qrsh_starter is used to start a command, optionally with additional
*     arguments, in a special environment.
*     The environment is read from the given <environment file>.
*     The command to be executed is read from the environment variable
*     QRSH_COMMAND and executed either standalone, passed to a wrapper
*     script (environment  variable QRSH_WRAPPER) or (default) in a users login
*     shell (<shell> -c <command>).
*     On exit of the command, or if an error occurs, an exit code is written
*     to the file $TMPDIR/qrsh_exit_code.
*
*     qrsh_starter is called from qrsh to start the remote processes in 
*     the correct environment.
*
*  INPUTS
*     environment file - file with environment information, each line 
*                        contains a tuple <name>=<value>
*     noshell          - if this parameter is passed, the command will be
*                        executed standalone
*
*  RESULT
*     EXIT_SUCCESS, if all actions could be performed,
*     EXIT_FAILURE, if an error occured
*
*  EXAMPLE
*     setenv QRSH_COMMAND "echo test"
*     env > ~/myenvironment
*     rsh <hostname> qrsh_starter ~/myenvironment 
*
*  SEE ALSO
*     Interactive/qsh/--Interactive
*
****************************************************************************
*/
int main(int argc, char *argv[])
{
   int   exitCode = 0;
   char *command  = NULL;
   char *wrapper = NULL;
   int  noshell  = 0;

   /* check for correct usage */
   if(argc < 2) {
      fprintf(stderr, "usage: %s <job spooldir> [noshell]\n", argv[0]);
      exit(EXIT_FAILURE);        
   }

   /* check for noshell */
   if(argc > 2) {
      if(strcmp(argv[2], "noshell") == 0) {
         noshell = 1;
      }
   }

   if(!readConfig(argv[1])) {
      writeExitCode(EXIT_FAILURE, 0);
      exit(EXIT_FAILURE);
   }

   /* setup environment */
   command = setEnvironment(argv[1], &wrapper);
   if(command == NULL) {
      writeExitCode(EXIT_FAILURE, 0);
      exit(EXIT_FAILURE);
   }   

   if(!changeDirectory()) {
      writeExitCode(EXIT_FAILURE, 0);
      exit(EXIT_FAILURE);
   }

   /* start job */
   exitCode = startJob(command, wrapper, noshell);

   /* JG: TODO: At this time, we could already pass the exitCode to qrsh.
    *           Currently, this is done by shepherd, but only after 
    *           qrsh_starter and rshd exited.
    *           If we pass exitCode to qrsh, we also have to implement the
    *           shepherd_about_to_exit mechanism here.
    */

   /* write exit code and exit */
   return writeExitCode(EXIT_SUCCESS, exitCode);
}
Ejemplo n.º 24
0
bool FatFsClass::initialize(void)
{
	/* setup sd card slot */
	if(!sd_raw_init()){
		return false;
	}

	/* open first partition */
	_partition = partition_open(sd_raw_read,
								sd_raw_read_interval,
#if SD_RAW_WRITE_SUPPORT
								sd_raw_write,
								sd_raw_write_interval,
#else
								0,
								0,
#endif
								0
								);

	if(!_partition){
		/* If the partition did not open, assume the storage device
		 * is a "superfloppy", i.e. has no MBR.
		 */
		_partition = partition_open(sd_raw_read,
									sd_raw_read_interval,
#if SD_RAW_WRITE_SUPPORT
									sd_raw_write,
									sd_raw_write_interval,
#else
									0,
									0,
#endif
									-1
									);
		if(!_partition){
			return false;
		}
	}

	/* open file system */
	_fs = fat_open(_partition);
	if(!_fs){
		return false;
	}

	/* open root directory */
	return changeDirectory("/");
}
void DockPixelStreamer::onItem()
{
    const QImage& image = flow_->slide( flow_->centerIndex( ));
    const QString& source = image.text( "source" );

    if( image.text( "dir" ).isEmpty( ))
    {
        Command command(COMMAND_TYPE_FILE, source);
        emit sendCommand(command.getCommand());
    }
    else
    {
        changeDirectory( source );
    }
}
Ejemplo n.º 26
0
// Functions related to the File Explorer Option : Start
void executeFileExplorerOption(int option){
	switch (option){
		case 1:
		  fileListSortByName();
		  break;
  		case 2:
		  fileListSortBySize();
		  break;
  		case 3:
		  changeDirectory();
		  break;
  		case 4:
		  displayMainMenu();
		  break;
	}
}
void MessageStorage::initialize(char * storageRoot, bool deleteOldQueue)
{
	if(storageRoot == NULL)
	{
		module_debug_strg("cannot work without storage root!");
		return;
	}
	
	strcpy(m_storageRoot, storageRoot);
	
	// mount the actual storage device we use for storing data
	module_debug_strg("mounting storage...");
	if(mountStorage())
		module_debug_strg("storage available!");
	else
		module_debug_strg("storage not available!");
	
	uint8_t cnt = 15;
	
	module_debug_strg("starting speed tests...");
	while(cnt--)
		FATFS_speedTest(8);
	
	module_debug_strg("end of speed tests...");
	
	module_debug_strg("changing to storage root: %s", m_storageRoot);
	// change to storage root
	changeDirectory(m_storageRoot);
	
	module_debug_strg("creating storage subdirs...");
	// create subdirectories
	createDirectory(SUBDIR_QUEUE);
	createDirectory(SUBDIR_AUDIO);
	createDirectory(SUBDIR_LOG);
	
	
	// count list of existing files in storage root,
	module_debug_strg("counting files...");
	
	// count disk files on queue
	m_queueCount = traverseDirectory(SUBDIR_QUEUE, &m_nextMessageSeqNumber, deleteOldQueue);
	
	// traverse audio samples as well to find latest seq number there
	// hardcoded to not remove old files, gut sound is a valuable commodity...
	traverseDirectory(SUBDIR_AUDIO, &m_nextAudioSeqNumber, false);
}
Ejemplo n.º 28
0
void changeDirectory() {
    //Find a directory name;
    char directoryName[256];
    printf("\n");
    printf("Directory name:");
    scanf("%s", directoryName);

    //Check the name whether in this directory;
    if(chdir(directoryName)==0) {
        fileExplorer();
    }
    else {
        printf("Cannot find your directory name!\n");
        printf("Please rewrite the directory name.\n");
        changeDirectory();
    }

}
Ejemplo n.º 29
0
void fileExplorer() {
    int choice2;

    printf("+++++++++++++++++++++++++++++++\n");
    printf("\n");
    printf("File Explorer\n");
    printf("\n");
    printf("1.File List(sorted by name)\n");
    printf("\n");
    printf("2.File List(sorted by size)\n");
    printf("\n");
    printf("3.Change Directory\n");
    printf("\n");
    printf("4.Main Menu\n");
    printf("\n");
    printf("+++++++++++++++++++++++++++++++\n");
    printf("\n");
    printf("Selection:");

    scanf("%d",&choice2);

    if(choice2==1) {
        //Go file list by name;
        system("clear");
        fileListByName();
    }
    else if (choice2==2) {
        //Go file list by size;
        system("clear");
        fileListBySize();
    }
    else if (choice2==3) {
        //Go changeDirectory;
        system("clear");
        changeDirectory();
    }
    else if(choice2==4) {
        //Go back to main menu;
        system("clear");
        mainMenu();
    }


}
Ejemplo n.º 30
0
Node *newFile(Node *root, char *absName, int flag)
{
	char *path = malloc(255),
	     *name = malloc(255);
	Node *node;
	if (!split(absName, path, name))
	{
		printf("ERROR: No such file or directory.\n");
		return root;
	}
	else if(strlen(name) == 0)
	{
		printf("ERROR: Couldn't create such file or directory.\n");
		return root;
	}
	
	node = changeDirectory(root,path);
	if (node == NULL) return root;
	if(flag)
	{
		if(findFile(node->listFile, name) != NULL)
				printf("ERROR: File or directory already exists.\n");
		else
		{
			node->listFile = add(node->listFile, newNode(name, path, flag,node));
			node->nFile++;
			
		}
	}
	else
	{
		if(findFile(node->listDir, name) != NULL)
				printf("ERROR: File or directory already exists.\n");
		else
		{
			node->listDir = add(node->listDir, newNode(name, path, flag, node));
			node->nFile++;
		}
	}
	return root;
}