Ejemplo n.º 1
0
void WriteToFile(char* buf,int leng, int which=0, int silent=0)
{
  FILE * pFile;
  char* nl = "\n\n";
  char buf2[255]={20};
  char pth[255]={0};

  if(!folder_exists("c:\\pages")) mkdir("c:\\pages");
  if(!folder_exists("c:\\posts")) mkdir("c:\\posts");

  switch(which){
	case 0: strcpy(pth,"c:\\pages");break;
	case 1: strcpy(pth,"c:\\posts");break;
    case 2: strcpy(pth,"c:\\wininet_log.txt");break;
  }

  if(which < 2){
	  if(newfile(pth)==0){
		if(silent==0) LogAPI("newfile returned 0 write failed?");
		return;
	  }
  }  
  
  if(silent==0) LogAPI("Writing to %s", pth);
  pFile = fopen ( pth , "ab" );
  fwrite(buf , 1 , leng , pFile );
  fclose (pFile);

}
END_TEST

START_TEST(test_folder_exists__nested) {
	stringer_t *deepdir = mkstringer("/tmp/deeply/nested/dir");
	ck_assert_int_eq(-1, folder_exists(deepdir, false));
	ck_assert_int_eq(-1, folder_exists(deepdir, true));
	st_free(deepdir);
}
END_TEST

START_TEST(test_folder_exists__nonexistent) {
	stringer_t *nonex = mkstringer("/nonexistent");
	ck_assert_int_eq(-1, folder_exists(nonex, false));
	ck_assert_int_eq(-1, folder_exists(nonex, true));
	st_free(nonex);
}
END_TEST

START_TEST(test_folder_exists__tmpdir) {
	stringer_t *tmpdir = mkstringer("/tmp/check_host_folder.d");
	ck_assert_int_eq(-1, folder_exists(tmpdir, false));
	ck_assert_int_eq(1, folder_exists(tmpdir, true));
	rmdir(st_data_get(tmpdir));
	st_free(tmpdir);
}
Ejemplo n.º 5
0
/*### BROADCAST A FOLDER RECURSIVELY ###########################*/
void Broadcast_Folder (char *idir, char *iprefix, char *odir, char *oprefix, int nProc, int myProc, MPI_Comm comm)
{
    int i, type;
    char **ofname, suffix[1000];
    char cmd[1000], ifname[1000], ifnamefull[1000], *ptr, *start;
    FILE * fp;


    ofname = (char **) malloc(sizeof(char *) * nProc);    
    for (i=0; i<nProc; i++) 
        ofname[i] = malloc(sizeof(char) * 1000);
    sprintf(cmd, "mkdir -p %s", odir);
    system(cmd);

    if (myProc == 0) {        
        sprintf(cmd, "ls %s/", idir);
        fp = popen(cmd, "r" );
        while ( fgets(ifname, sizeof(ifname), fp) != NULL ) {            
            ptr = strrchr(ifname, '\n');
            *ptr = '\0'; //replace newline            
            ptr = strrchr(ifname, '/');
            start = (ptr == NULL) ? ifname : ptr+1; //find the start of iprefix            

            for (i=0; iprefix[i] != '\0'; i++) //check if file/foldername starts with the iprefix
                if (iprefix[i] != start[i]) 
                    break;
            if (iprefix[i] != '\0')
                continue;
            ptr = start + i; //skip the prefix                                

            sprintf(ifnamefull, "%s/%s", idir, start); //to make sure ifname path is correct
            type = folder_exists(ifnamefull) ? 1 : 0;
            MPI_Bcast(&type, 1, MPI_INT, 0, comm);     //let others know what will be sent 
            MPI_Bcast(ptr, 1000, MPI_CHAR, 0, comm);   //send suffix of output file/folder name to others
            sprintf(ofname[myProc], "%s/%s%s", odir, oprefix, ptr);
            if (type == 0)                                       //send file to others
                Broadcast_File(ifnamefull, ofname, 0, myProc, comm); 
            else                                                 //send folder to others
                Broadcast_Folder(ifnamefull, "", ofname[myProc], "", nProc, myProc, comm);
        }
        pclose(fp);
        type = -1; 
        MPI_Bcast(&type, 1, MPI_INT, 0, comm);         //let others know that nothing else will be sent
    } else {
        while(1) {
            MPI_Bcast(&type, 1, MPI_INT, 0, comm);
            if (type == -1) 
                break;            
            MPI_Bcast(suffix, 1000, MPI_CHAR, 0, comm);
            sprintf(ofname[myProc], "%s/%s%s", odir, oprefix, suffix);
            if (type == 0) 
                Broadcast_File(NULL, ofname, 0, myProc, comm); 
            else
                Broadcast_Folder(NULL, NULL, ofname[myProc], "", nProc, myProc, comm);
        }
    }
    for (i=0; i<nProc; i++) 
        free(ofname[i]);
    free(ofname);
}
Ejemplo n.º 6
0
bool folder_writable (const std::string& directory)
{
  // a folder is writable if it exists and has write access
  std::string dir = directory;
  if (dir.empty()) dir = ".";
  if (!folder_exists(dir)) return false;
  return access(dir.c_str(),W_OK)==0;
}
Ejemplo n.º 7
0
    /**
     * Recursive, portable wrapper for mkdir.
     * @param[in] path the full path of the directory to create.
     * @return zero on success, otherwise -1.
     */
    int mkdir(const char *path)
    {
        std::string current_level = "";
        std::string level;
        std::stringstream ss(path);

#ifdef WIN32
        // Get drive letter & colon (windows only)
        std::string drive;
        if (std::getline(ss, drive, ':'))
        {
#ifdef MKDIR_DEBUG_2
          std::cout << "Mkdir: Drive: " << drive << "\n";
#endif
          current_level = drive + ":/";
        }
#endif
        // split path using slash as a separator
        while (std::getline(ss, level, '/'))
        {
            if (level.empty()) // j.c. fix
            {
                current_level += "/"; // don't forget to append a slash
                continue;
            }
            current_level += level; // append folder to the current level
#ifdef MKDIR_DEBUG_2
            std::cout << "mkdir: current_level: \"" << current_level << "\"\n";
#endif
            // create current level
            if (folder_exists(current_level))
            {
#ifdef MKDIR_DEBUG_2
                std::cout << "Folder DOES exist: " << current_level << "\n";
#endif
            }
            else
            {
#ifdef MKDIR_DEBUG
                std::cout << "Folder does not exist: " << current_level << " - creating...\n";
#endif
                if (_mkdir(current_level.c_str()) != 0)
                {
                    std::cout << "FAILED to create folder " << current_level << "!!\n";
                    return -1;
                }
            }

            current_level += "/"; // don't forget to append a slash
        }

        return 0;
    }
Ejemplo n.º 8
0
bool folder_set_current(const std::string& folder)
{
  if (!folder_exists(folder))
    return false;
#ifdef _WIN32
  // Windose implementation - this returns non-zero for success
  return (SetCurrentDirectory(folder.c_str()) != 0);
#else
  // Unix implementation - this returns zero for success
  return (chdir(folder.c_str()) == 0);
#endif
}
Ejemplo n.º 9
0
bool create_folder(const char *path)
{
   // Sanitize path
   char folderpath[4096];
   char folderbuf[4096];
   strncpy(folderpath, path, sizeof(folderpath));
   folderpath[sizeof(folderpath)-1] = '\0';
   fix_path(folderpath);
   folderbuf[0] = '\0';
   
   // Iterate and create
   const char *ptr = folderpath;
   unsigned int pathItr = 0;
   while((ptr = strchr(ptr, '/')) != NULL)
   {
      if (ptr - folderpath > 0)
      {
         strncpy(folderbuf, folderpath, ptr - folderpath);
         folderbuf[(ptr-folderpath)] = 0;
      }
      
      if (strlen(folderbuf) > 0 && !folder_exists(folderbuf))
      {
         if (mkdir(folderbuf, 0700) != 0)
            return false;
      }
      
      ptr++;
   }
   
   // Sort out final /
   if (strlen(path) > 0 && !folder_exists(path))
   {
      if (mkdir(path, 0700) != 0)
         return false;
   }
   
   return true;
}
Ejemplo n.º 10
0
/*
Sets the new data folder path. If the path is too long, short, or otherwise
invalid, nothing is changed and false is returned.
RETURNS true on success
*/
bool set_data_folder(
    const char * s
){
    u32 l = strlen(s);
    if(l < 2 || l >= MAX_PATH_SIZ - 2)
        return false;

    if(folder_exists(s))
        return false;

    if(s[l - 1] == '/')
        snprintf(_data_folder, MAX_PATH_SIZ, "%s", s);
    else
        snprintf(_data_folder, MAX_PATH_SIZ, "%s/", s);

    return true;
}
Ejemplo n.º 11
0
bool Clustering::cluster_exists(const char *folder){
	ASSERTINFO(folder == NULL, "IPP");

	bool status = true;
	if(!folder_exists(folder)){
		return false;
	}else{
		char filename[255];
		sprintf(filename, "%s/%s", folder, FileCentroid);
		status &= file_exists(filename);

		sprintf(filename, "%s/%s", folder, FileMember);		
		status &= file_exists(filename);
	}

	return status;
}
Ejemplo n.º 12
0
bool folder_delete (const std::string& directory, bool recurse)
{
  std::string dir = directory;
  if (dir.empty()) dir = ".";
  if (!folder_exists(dir)) return false;
  bool result = true;
  // depth-first traversal ensures that directory contents are deleted before trying to delete the directory itself
  if (recurse)
  {
    std::vector<std::string> subdirectories = folder_subdirectories(dir);
    for (std::vector<std::string>::size_type d = 0; d < subdirectories.size(); ++d)
      if (!folder_delete(folder_down(dir,subdirectories[d]),true)) 
	result = false;
    std::vector<std::string> files = folder_files(dir);
    for (std::vector<std::string>::size_type f = 0; f < files.size(); ++f)
      if (!file_delete(create_filespec(dir, files[f]))) 
	result = false;
  }
  if (rmdir(dir.c_str())!=0) result = false;
  return result;
}
Ejemplo n.º 13
0
bool_t log_start(void) {

	FILE *file_out, *file_err;
	chr_t *log_file = MEMORYBUF(1024);

	// File logging.
	if (magma.output.file && magma.output.path) {

		log_date = time_datestamp();

		if (snprintf(log_file, 1024, "%s%smagmad.%lu.log", magma.output.path, (*(ns_length_get(magma.output.path) + magma.output.path) == '/') ? "" : "/",
			log_date) >= 1024) {
			log_critical("Log file path exceeded available buffer. { file = %s%smagmad.%lu.log }", magma.output.path,
				(*(ns_length_get(magma.output.path) + magma.output.path) == '/') ? "" : "/", log_date);
			return false;
		}

		if (folder_exists(NULLER(magma.output.path), false)) {
			log_critical("The path configured to hold the output log files does not exist. { path = %s }", magma.output.path);
			return false;
		}

		if (!(file_out = freopen64(log_file, "a+", stdout))) {
			log_critical("Unable to open the error log, sticking with standard out. { file = %s }", log_file);
			return false;
		}

		if (!(file_err = freopen64(log_file, "a+", stderr))) {
			log_critical("Unable to open the error log, sticking with standard error. { file = %s }", log_file);
			fclose(file_out);
			return false;
		}

		stdout = file_out;
		stderr = file_err;
	}

	fclose(stdin);
	return true;
}
Ejemplo n.º 14
0
/*----------------------------------------------------------------------
     Offer to delete old sent-mail folders

  Args: sml -- The list of sent-mail folders
 
  ----*/
int
prune_folders(CONTEXT_S *prune_cntxt, char *folder_base, int cur_month,
	      char *type, unsigned int pr)
{
    char         path2[MAXPATH+1],  prompt[128], tmp[21];
    int          month_to_use, exists;
    struct sm_folder *mail_list, *sm;

    mail_list = get_mail_list(prune_cntxt, folder_base);
    free_folder_list(prune_cntxt);

#ifdef	DEBUG
    for(sm = mail_list; sm != NULL && sm->name != NULL; sm++)
      dprint((5,"Old sent-mail: %5d  %s\n", sm->month_num,
	     sm->name[0] ? sm->name : "?"));
#endif

    for(sm = mail_list; sm != NULL && sm->name != NULL; sm++)
      if(sm->month_num == cur_month - 1)
        break;  /* matched a month */
 
    month_to_use = (sm == NULL || sm->name == NULL) ? cur_month - 1 : 0;

    dprint((5, "Month_to_use : %d\n", month_to_use));

    if(month_to_use == 0 || pr == PRUNE_NO_AND_ASK || pr == PRUNE_NO_AND_NO)
      goto delete_old;

    strncpy(path2, folder_base, sizeof(path2)-1);
    path2[sizeof(path2)-1] = '\0';

    if(F_ON(F_PRUNE_USES_ISO,ps_global)){             /* sent-mail-yyyy-mm */
	snprintf(path2 + strlen(path2), sizeof(path2)-strlen(path2), "-%4.4d-%2.2d", month_to_use/12,
		month_to_use % 12 + 1);
    }
    else{
	strncpy(tmp, month_abbrev((month_to_use % 12)+1), 20);
	tmp[sizeof(tmp)-1] = '\0';
	lcase((unsigned char *) tmp);
#ifdef	DOS
	if(*prune_cntxt->context != '{'){
	  int i;

	  i = strlen(path2);
	  snprintf(path2 + (size_t)((i > 4) ? 4 : i),
	           sizeof(path2)- ((i > 4) ? 4 : i),
		  "%2.2d%2.2d", (month_to_use % 12) + 1,
		  ((month_to_use / 12) - 1900) % 100);
	}
	else
#endif
	snprintf(path2 + strlen(path2), sizeof(path2)-strlen(path2), "-%.20s-%d", tmp, month_to_use/12);
    }

    Writechar(BELL, 0);
    snprintf(prompt, sizeof(prompt), "Move current \"%.50s\" to \"%.50s\"", folder_base, path2);
    if((exists = folder_exists(prune_cntxt, folder_base)) == FEX_ERROR){
        dprint((5, "prune_folders: Error testing existence\n"));
        return(0);
    }
    else if(exists == FEX_NOENT){	/* doesn't exist */
        dprint((5, "prune_folders: nothing to prune <%s %s>\n",
		   prune_cntxt->context ? prune_cntxt->context : "?",
		   folder_base ? folder_base : "?"));
        goto delete_old;
    }
    else if(!(exists & FEX_ISFILE)
	    || pr == PRUNE_NO_AND_ASK || pr == PRUNE_NO_AND_NO
	    || ((pr == PRUNE_ASK_AND_ASK || pr == PRUNE_ASK_AND_NO) &&
	        want_to(prompt, 'n', 0, h_wt_expire, WT_FLUSH_IN) == 'n')){
	dprint((5, "User declines renaming %s\n",
	       ps_global->VAR_DEFAULT_FCC ? ps_global->VAR_DEFAULT_FCC : "?"));
	goto delete_old;
    }

    prune_move_folder(folder_base, path2, prune_cntxt);

  delete_old:
    if(pr == PRUNE_ASK_AND_ASK || pr == PRUNE_YES_AND_ASK
       || pr == PRUNE_NO_AND_ASK)
      delete_old_mail(mail_list, prune_cntxt, type);

    if((sm = mail_list) != NULL){
	while(sm->name){
	    fs_give((void **)&(sm->name));
	    sm++;
	}

        fs_give((void **)&mail_list);
    }

    return(1);
}
Ejemplo n.º 15
0
/*### MAIN ########################################################################*/    
int main (int argc, char *argv[]) {
    int i, j;
    char *readsfile, *readsfile2 = NULL, *indexdir=NULL, *indexprefix=NULL, *mainworkdir, *outdir, workdir[1000];
    char command[1000], usage[1000];
    int ninpfile = 0;
    char inpfile[10][1000], **ofname;    
    char fname1[500];
    int nline_per_read = -1;
    MPI_Comm comm=MPI_COMM_WORLD;
    int myProc, nProc;
    FILE *pfp;
    double times[5][2];

    //#############################################
    //### PARSE INPUT PARAMETERS ##################
    sprintf(usage, "Usage: %s <work directory> <output directory> <reads file> [-r <reads file2>] [-l <num.of lines per read>] [-i <index directory> <index prefix>] [-f <inpfile>]\n", argv[0]); 

    MPI_Init(&argc, &argv);
    MPI_Comm_size(comm, &nProc);
    MPI_Comm_rank(comm, &myProc);
    if (argc < 4) {
        if (myProc == 0)
            printf("%s", usage);
        exit(-1);
    }
    i=1;
    mainworkdir = argv[i++];
    outdir = argv[i++];
    readsfile = argv[i++];
    for ( ; i<argc ; i++) {
        if (!strcmp(argv[i], "-r")) {
            readsfile2 = argv[++i];                        
        } else if (!strcmp(argv[i], "-i")) {
            indexdir = argv[++i];
            indexprefix = argv[++i];
        } else if (!strcmp(argv[i], "-f")) {
            if (ninpfile > 10 && myProc == 0) {
                fprintf (stderr, "pmap_dist error: At most 10 inpfiles can be specified\n");
                exit(-1);
            }
            strcpy(inpfile[ninpfile++], argv[++i]);
        } else if (!strcmp(argv[i], "-l")) {
            nline_per_read = atoi(argv[++i]);
            if (nline_per_read <= 0 && myProc == 0) {
                fprintf(stderr, "pmap_dist error: Number of lines per read should be greater than 0\n");
                exit(-1);
            }
        } else if (myProc == 0) {
            fprintf (stderr, "pmap_dist error: Unknown option %s\n", argv[i]);
            exit(-1);
        }
    }    
    
    // Create a workdir, indexdir and outdir 
    sprintf(workdir, "%s/pmap_node%d", mainworkdir, myProc); 
    sprintf(command, "mkdir -p %s/index", workdir);
    system(command);
    if (myProc == 0) {
        sprintf(command, "mkdir -p %s", outdir);
        system(command);
    }

    // Check if files/folders exist
    if (myProc == 0) {
        if (indexdir && !folder_exists(indexdir)) {
            if (indexdir[0] != '/')
                fprintf(stderr, "pmap_dist error: Cannot find indexdir: %s. Make sure the path is an absolute path.\n", indexdir);
            else
                fprintf(stderr, "pmap_dist error: Cannot find indexdir: %s\n", indexdir);
            exit(-1);
        }
        if (!file_exists(readsfile)) {
            if (readsfile[0] != '/')
                fprintf(stderr, "pmap_dist error: Cannot find readsfile: %s. Make sure the path is an absolute path.\n", readsfile);
            else
                fprintf(stderr, "pmap_dist error: Cannot find readsfile: %s\n", readsfile);
            exit(-1);
        }
        if (readsfile2 && !file_exists(readsfile2)) {
            if (readsfile2[0] != '/')
                fprintf(stderr, "pmap_dist error: Cannot find readsfile2: %s. Make sure the path is an absolute path.\n", readsfile2);
            else
                fprintf(stderr, "pmap_dist error: Cannot find readsfile2: %s\n", readsfile2);
            exit(-1);
        }
        for (i=0; i<ninpfile; i++) {
            if (!file_exists(inpfile[i])) {
                if (inpfile[i][0] != '/')
                    fprintf(stderr, "pmap_dist error: Cannot find inpfile: %s. Make sure the path is an absolute path.\n", inpfile[i]);
                else
                    fprintf(stderr, "pmap_dist error: Cannot find inpfile: %s\n", inpfile[i]);
                exit(-1);
            }
        }        
        if (nline_per_read == -1) {
            nline_per_read = get_nline_per_read(readsfile);
        }
    }

    // Memory allocation
    ofname = (char **) malloc(sizeof(char *) * nProc);    
    for (i=0; i<nProc; i++) 
        ofname[i] = malloc(sizeof(char) * 1000);
            
    
    
    //#########################################################
    //### PARTITION/DISTRIBUTE THE DATA #######################
    times[1][0] = u_wseconds();
    sprintf(fname1, "%s/pmap.reads", workdir);
    Partition_Reads (readsfile, fname1, nline_per_read, nProc, myProc, comm);
    if (readsfile2) {
        sprintf(fname1, "%s/pmap.reads2", workdir);
        Partition_Reads (readsfile2, fname1, nline_per_read, nProc, myProc, comm);
    }
    times[1][1] = u_wseconds();    

    times[2][0] = u_wseconds();
    if (indexdir) {
        sprintf(fname1, "%s/index", workdir);
        Broadcast_Folder(indexdir, indexprefix, fname1, "index", nProc, myProc, comm);
    }
    times[2][1] = u_wseconds();    

    times[3][0] = u_wseconds();
    for (i=0; i<ninpfile; i++) {
        char *ptr = strrchr(inpfile[i], '/');
        for (j=0; j<nProc; j++) 
            sprintf(ofname[j], "%s/%s", workdir, ptr+1);
        Broadcast_File(inpfile[i], ofname, 0, myProc, comm);
    }
    times[3][1] = u_wseconds();    
    
    //#########################################################
    //### PRINT TIMING INFO AND FINALIZE ######################
    if (myProc == 0) {
        sprintf(fname1, "%s/dist_time.txt", outdir); 
        pfp = fopen(fname1, "w");           
        fprintf(pfp, "Partition reads     : %8.1lf\n", times[1][1]-times[1][0]);
        fprintf(pfp, "Replicate index     : %8.1lf\n", times[2][1]-times[2][0]);
        fprintf(pfp, "Replicate inpfile(s): %8.1lf\n", times[3][1]-times[3][0]);
        fclose(pfp);
    }            
    for (i=0; i<nProc; i++) 
        free(ofname[i]);
    free(ofname);    
    MPI_Finalize();
    return 0;    
}
void fontDownload(string fontname)
{
	bool stop = true;

	GuiWindow promptWindow(520,360);
	promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
	promptWindow.SetPosition(0, -10);
	GuiTrigger trigA;
	trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);


	GuiImageData dialogBox(Theme.dialog_background);
	GuiImage dialogBoxImg(&dialogBox);

	GuiImageData btnOutline(Theme.button_small);
	GuiImage btn1Img(&btnOutline);
	GuiImage btn2Img(&btnOutline);

	GuiImageData btnOutlineOver(Theme.button_small_focus);
	GuiImage btn1ImgOver(&btnOutlineOver);
	GuiImage btn2ImgOver(&btnOutlineOver);

	GuiText titleTxt(tr("Download"), 26, (GXColor){Theme.text_1, Theme.text_2, Theme.text_3, 255});
	titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
	titleTxt.SetPosition(0, 40);
	GuiText downloadTxt(tr("Downloading file..."), 22, (GXColor){Theme.text_1, Theme.text_2, Theme.text_3, 255});
	downloadTxt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
	downloadTxt.SetPosition(0, -20);

	GuiText msgTxt(tr("please wait"), 22, (GXColor){Theme.text_1, Theme.text_2, Theme.text_3, 255});
	msgTxt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
	msgTxt.SetPosition(0, 20);

	GuiText btn1Txt(tr("OK"), 22, (GXColor){Theme.button_small_text_1, Theme.button_small_text_2, Theme.button_small_text_3, 255});
	GuiButton btn1(btnOutline.GetWidth(), btnOutline.GetHeight());

	btn1.SetAlignment(ALIGN_CENTRE, ALIGN_BOTTOM);
	btn1.SetPosition(0, -25);
	btn1.SetLabel(&btn1Txt);
	btn1.SetImage(&btn1Img);
	btn1.SetImageOver(&btn1ImgOver);
	btn1.SetTrigger(&trigA);
	btn1.SetState(STATE_SELECTED);
	btn1.SetEffectGrow();

	promptWindow.Append(&dialogBoxImg);
	promptWindow.Append(&titleTxt);
	promptWindow.Append(&downloadTxt);
	promptWindow.Append(&msgTxt);


	HaltGui();
	mainWindow->SetState(STATE_DISABLED);
	mainWindow->Append(&promptWindow);
	mainWindow->ChangeFocus(&promptWindow);
	ResumeGui();

	char buffer[100];
	msgTxt.SetText(fontname.c_str());
	sprintf(buffer, "http://www.nanolx.org/hbf/Fonts/%s", fontname.c_str());
	struct block file = downloadfile(buffer);
	if (file.data && file.size > 0 && folder_exists())
	{
		FILE * data = fopen((Settings.device_dat + ":/config/HBF/Fonts/"+ fontname).c_str(), "wb");
		if(data)
		{
			fwrite(file.data, 1, file.size, data);
			fclose(data);
		}
	}
	if(file.data)
		free(file.data);

	msgTxt.SetText("");
	downloadTxt.SetText(tr("finished"));

	promptWindow.Append(&btn1);


	while(stop)
	{
		usleep(100);

		if(btn1.GetState() == STATE_CLICKED)
			stop = false;
	}

	HaltGui();
	mainWindow->Remove(&promptWindow);
	mainWindow->SetState(STATE_DEFAULT);
	ResumeGui();
}
Ejemplo n.º 17
0
bool folder_rename (const std::string& old_directory, const std::string& new_directory)
{
  if (!folder_exists(old_directory)) return false;
  return rename(old_directory.c_str(), new_directory.c_str())==0;
}