コード例 #1
0
/*
* Given a local directory, do the equivalent of `rm -rf`
* on it, but using the actual filesystem API.
* You can't just use dir->Remove() because that
* gives an error if the directory is not empty.
*/
void
rm_rf(BDirectory *dir)
{
  status_t err;
  BEntry entry;
  err = dir->GetNextEntry(&entry);
  while(err==B_OK)
  {
    BFile file = BFile(&entry, B_READ_ONLY);
    if(file.IsDirectory())
    {
      BDirectory ndir = BDirectory(&entry);
      rm_rf(&ndir);
    }

    err = entry.Remove();
    if(err != B_OK)
    {
      BPath path;
      entry.GetPath(&path);
      printf("Remove Error: %s on %s\n",strerror(err),path.Path());
      //what to do if I can't remove something?
    }

    err = dir->GetNextEntry(&entry);
  }
  err = dir->GetEntry(&entry);
  err = entry.Remove();
  if(err != B_OK)
    printf("Folder Removal Error: %s\n", strerror(err));
}
コード例 #2
0
ファイル: MSN.cpp プロジェクト: ModeenF/Caya
status_t
MSNP::Init(CayaProtocolMessengerInterface* msgr)
{
	fServerMsgr = msgr;
	fLogged = false;

	fClientID = 0;
	fClientID += MSN::MSNC7;
	fClientID += MSN::MSNC6;
	fClientID += MSN::MSNC5;
	fClientID += MSN::MSNC4;
	fClientID += MSN::MSNC3;
	fClientID += MSN::MSNC2;
	fClientID += MSN::MSNC1;
	fClientID += MSN::SupportWinks;
	fClientID += MSN::VoiceClips;
	fClientID += MSN::InkGifSupport;
	fClientID += MSN::SIPInvitations;
	fClientID += MSN::SupportMultiPacketMessaging;

	fID = 963396;

	BPath path;
	status_t ret = find_directory(B_USER_CONFIG_DIRECTORY, &path);
	if (ret != B_OK)
		return ret;

	BDirectory cacheDir = BDirectory(path.Path());
	path.Append("settings/Caya/Cache/msn/");
	cacheDir.CreateDirectory(path.Path(), NULL);

	fCachePath = path;

	return B_OK;
}
コード例 #3
0
ファイル: TaskFS.cpp プロジェクト: Paradoxianer/Tasks
status_t TaskFS::PrepareFirstStart()
{
	status_t err = B_OK;
	//first create the task directory
	BPath homeDir;
	find_directory(B_USER_DIRECTORY, &homeDir);

	BString tasksDirString = homeDir.Path();
	tasksDirString << "/" << TASK_DIRECTORY;

	tasksDir = BDirectory(tasksDirString.String());
	//if the folder was not found create it
	if (tasksDir.InitCheck() != B_OK) {
		BDirectory homeDirectory(homeDir.Path());
		err = homeDirectory.CreateDirectory(TASK_DIRECTORY,
			&tasksDir);
		if (err != B_OK)
			printf("Failed to create tasks directory (%s)\n",
				strerror(err));
		ssize_t written = tasksDir.WriteAttr("_trk/columns_le", B_RAW_TYPE,
			0, task_columns, sizeof(task_columns));
		if (written < 0)
			printf("Failed to write column info (%s)\n", strerror(written));
	}
	SetUpMimeTyp();
	return err;
}
コード例 #4
0
ファイル: TaskFS.cpp プロジェクト: Paradoxianer/Tasks
status_t TaskFS::TaskToFile(Task *theTask, bool overwrite)
{
	BFile		taskFile;
	BEntry		entry;
	status_t	err;
	TaskList	*tskLst	= theTask->GetTaskList();
	
	BDirectory	dir		= BDirectory();

	bool	completed	= theTask->IsCompleted();
	uint32	priority	= theTask->Priority();
	time_t	due			= theTask->DueTime();


	//first find directory.. then create files in this directory
	if (tskLst!=NULL)
		dir.SetTo(&tasksDir,tskLst->Name());
	else
		dir.SetTo(&tasksDir,".");

	
	//first check if the File already exists..
	//if not and overwrite is on check the ids..
	// and search for the correspondending file...

	if (dir.FindEntry(theTask->Title(),&entry) == B_OK) {
		taskFile.SetTo((const BEntry*)&entry,B_READ_WRITE);
		err = B_OK;
	} 
	else {
		entry_ref *ref= FileForId(theTask);
		if (ref==NULL){
			dir.CreateFile(theTask->Title(),&taskFile,overwrite);
			dir.FindEntry(theTask->Title(),&entry);
		}
		else {
			entry.SetTo(ref);
			taskFile.SetTo((const BEntry*)ref,B_READ_WRITE);
		}
	}
	if (taskFile.InitCheck() == B_OK){
		taskFile.WriteAttr("META:completed",B_BOOL_TYPE, 0, &completed, sizeof(completed));
		entry.Rename(theTask->Title());
		taskFile.WriteAttrString("META:tasks",new BString(theTask->GetTaskList()->ID()));
		taskFile.WriteAttrString("META:notes",new BString(theTask->Notes()));
		taskFile.WriteAttr("META:priority", B_UINT32_TYPE, 0, &priority, sizeof(priority));
		taskFile.WriteAttr("META:due", B_TIME_TYPE, 0, &due, sizeof(due));
		taskFile.WriteAttrString("META:task_id",  new BString(theTask->ID()));
		taskFile.WriteAttrString("META:task_url",new BString(theTask->URL()));
	}
	else
		err=B_ERROR;
	return err; 
}
コード例 #5
0
ファイル: TheApp.cpp プロジェクト: Barrett17/Caya
void	
TheApp::ReadyToRun()
{
	app_info theInfo;

	fMainWin = new MainWindow();

	if (be_app->GetAppInfo(&theInfo) == B_OK) {
		BPath appDir(&theInfo.ref);
		appDir.GetParent(&appDir);

		// Emoticons settings
		BPath currentPath = appDir;
		currentPath.Append("smileys");
		currentPath.Append("settings.xml");

		// Load emoticons
		BEntry entry(currentPath.Path());
		if (entry.Exists())
			Emoticor::Get()->LoadConfig(currentPath.Path());
		else {
			BString msg("Can't find smileys settings in:\n\n");
			msg << currentPath.Path();
			BAlert* alert = new BAlert("", msg.String(), "Ouch!");
			alert->Go();
		}
		printf("Loaded Emoticons settings from: %s\n", currentPath.Path());

		currentPath = appDir;
		currentPath.Append("protocols");
		if (BEntry(currentPath.Path()).Exists()) {
			printf("Looking for protocols from: %s\n", currentPath.Path());

			ProtocolManager::Get()->Init(BDirectory(currentPath.Path()),
				fMainWin);
		} else {
			BString msg("Can't find protocols in:\n\n");
			msg << currentPath.Path();
			BAlert* alert = new BAlert("", msg.String(), "Ouch!");
			alert->Go();
			PostMessage(B_QUIT_REQUESTED);
			return;
		}
	}

	fMainWin->Start();
	fMainWin->Show();
}
コード例 #6
0
ファイル: InfoBox.cpp プロジェクト: carriercomm/Helios
void InfoBox::GetFolder(BDirectory dir) {

	int32 c=dir.CountEntries();
	BEntry entry;
	
	if (c>0)
	for (int32 i=0; i<c; i++) {
		dir.GetNextEntry(&entry, true);
		if (entry.IsDirectory()) {
			folders++;
			GetFolder(BDirectory(&entry));
		}
		else
			files++;
	}
}
コード例 #7
0
/*
* Message Handling Function
* If it's a node monitor message,
* then figure out what to do based on it.
* Otherwise, let BApplication handle it.
*/
void
App::MessageReceived(BMessage *msg)
{
  printf("message received:\n");
  msg->PrintToStream();
  switch(msg->what)
  {
    case MY_DELTA_CONST:
    {
      printf("Pulling changes from Dropbox\n");
      pull_and_apply_deltas();
      break;
    }
    case B_NODE_MONITOR:
    {
      printf("Received Node Monitor Alert\n");
      status_t err;
      int32 opcode;
      err = msg->FindInt32("opcode",&opcode);
      if(err == B_OK)
      {
        switch(opcode)
        {
          case B_ENTRY_CREATED:
          {
            printf("CREATED NEW FILE\n");
            entry_ref ref;
            BPath path;
            const char * name;

            // unpack the message
            msg->FindInt32("device",&ref.device);
            msg->FindInt64("directory",&ref.directory);
            msg->FindString("name",&name);
            ref.set_name(name);

            BEntry new_file = BEntry(&ref);
            new_file.GetPath(&path);


            //if we said to ignore a `NEW` msg from the path, then ignore it
            if(this->ignore_created(&path)) return;

            this->track_file(&new_file);

            if(new_file.IsDirectory())
            {
               add_folder_to_dropbox(path.Path());
               BDirectory new_dir = BDirectory(&new_file);
               this->recursive_watch(&new_dir);
            }
            else
            {
              BString *result = add_file_to_dropbox(path.Path());
              BString *real_path = parse_path(result);
              BString *parent_rev = parse_parent_rev(result);
              delete result;

              printf("path:|%s|\nparent_rev:|%s|\n",real_path->String(),parent_rev->String());

              BNode node = BNode(&new_file);
              set_parent_rev(&node,parent_rev);
              delete parent_rev;
              BPath new_path = BPath(db_to_local_filepath(real_path->String()).String());

              if(strcmp(new_path.Leaf(),path.Leaf()) != 0)
              {
                printf("moving %s to %s\n", path.Leaf(), new_path.Leaf());
                BEntry entry = BEntry(path.Path()); //entry for local path
                status_t err = entry.Rename(new_path.Leaf(),true);
                if(err != B_OK) printf("error moving: %s\n",strerror(err));
              }
              
              delete real_path;
              watch_entry(&new_file,B_WATCH_STAT);
            }
            break;
          }
          case B_ENTRY_MOVED:
          {
            printf("MOVED FILE\n");
            entry_ref eref;
            BDirectory from_dir, to_dir;
            node_ref from_ref,to_ref,nref;
            BPath path;
            const char* name;

            msg->FindInt32("device",&from_ref.device);
            msg->FindInt32("device",&to_ref.device);
            msg->FindInt32("device",&eref.device);
            msg->FindInt32("device",&nref.device);

            msg->FindInt64("from directory",&from_ref.node);
            msg->FindInt64("to directory",&to_ref.node);
            msg->FindInt64("to directory",&eref.directory);

            msg->FindInt64("node",&nref.node);

            msg->FindString("name",&name);
            eref.set_name(name);

            err = from_dir.SetTo(&from_ref);
            err = to_dir.SetTo(&to_ref);

            BEntry dest_entry = BEntry(&eref);
            BEntry test = BEntry("/boot/home/Dropbox/hi");
            BDirectory dropbox_local = BDirectory(local_path_string);
            bool into_dropbox = dropbox_local.Contains(&dest_entry);
            int32 index = this->find_nref_in_tracked_files(nref);
            if((index >= 0) && into_dropbox)
            {
              printf("moving within dropbox\n");
              BPath *old_path = (BPath*)this->tracked_filepaths.ItemAt(index);
              BPath new_path;
              dest_entry.GetPath(&new_path);

              char *argv[3];
              argv[0] = "db_mv.py";
              BString opath = local_to_db_filepath(old_path->Path());
              BString npath = local_to_db_filepath(new_path.Path());
              char not_const_o[opath.CountChars()];
              char not_const_n[npath.CountChars()];
              strcpy(not_const_o,opath.String());
              strcpy(not_const_n,npath.String());
              argv[1] = not_const_o;
              argv[2] = not_const_n;
              run_python_script(argv,3);

              old_path->SetTo(&dest_entry);
            }
            else if(index >= 0)
            {
              printf("moving the file out of dropbox\n");
              BPath *old_path = (BPath*)this->tracked_filepaths.ItemAt(index);
              delete_file_on_dropbox(old_path->Path());
              this->tracked_files.RemoveItem(index);
              this->tracked_filepaths.RemoveItem(index);
            }
            else if(into_dropbox)
            {
              printf("moving file into dropbox\n");
              BPath new_path;
              dest_entry.GetPath(&new_path);

              this->track_file(&dest_entry);

              if(dest_entry.IsDirectory())
              {
                 add_folder_to_dropbox(new_path.Path());
                 BDirectory new_dir = BDirectory(&dest_entry);
                 this->recursive_watch(&new_dir);
              }
              else
              {
                add_file_to_dropbox(new_path.Path());
                watch_entry(&dest_entry,B_WATCH_STAT);
              }
            }
            else
            {
              printf("moving unrelated file...?\n");
            }

            break;
          }
          case B_ENTRY_REMOVED:
          {
            printf("DELETED FILE\n");
            node_ref nref;
            msg->FindInt32("device", &nref.device);
            msg->FindInt64("node", &nref.node);

            int32 index = this->find_nref_in_tracked_files(nref);
            if(index >= 0)
            {
              BPath *path = (BPath*)this->tracked_filepaths.ItemAt(index);
              printf("local file %s deleted\n",path->Path());
              
              if(ignore_removed(path)) return;

              delete_file_on_dropbox(path->Path());
              this->tracked_files.RemoveItem(index);
              this->tracked_filepaths.RemoveItem(index);
            }
            else
            {
              printf("could not find deleted file\n");
            }

            break;
          }
          case B_STAT_CHANGED:
          {
            printf("EDITED FILE\n");
            node_ref nref;
            msg->FindInt32("device", &nref.device);
            msg->FindInt64("node", &nref.node);

            int32 index = this->find_nref_in_tracked_files(nref);
            if(index >= 0)
            {
              BPath *path = (BPath*)this->tracked_filepaths.ItemAt(index);
              if(ignore_edited(path)) return;
              BNode node = BNode(path->Path());
              BString * rev = get_parent_rev(&node);
              printf("parent_rev:|%s|\n",rev->String());
              
              update_file_in_dropbox(path->Path(),rev->String());
            }
            else
            {
              printf("Could not find edited file\n");
            }
            break;
          }
          default:
          {
            printf("default case opcode...\n");
          }
        }
      }
      break;
    }
    default:
    {
      BApplication::MessageReceived(msg);
      break;
    }
  }
}
コード例 #8
0
/*
* Given a single line of the output of db_delta.py
* Figures out what to do and does it.
* (adds and removes files and directories)
*/
int
App::parse_command(BString command)
{
  command.RemoveAll("\n"); //remove trailing whitespace
  if(command.Compare("RESET") == 0)
  {
    printf("Burn Everything. 8D\n");

    status_t err = stop_watching(be_app_messenger);
    if(err != B_OK) printf("stop_watching error: %s\n",strerror(err));

    BDirectory dir = BDirectory(local_path_string);
    rm_rf(&dir);

    BString str = BString("/"); //create_local_path wants a remote path 
    create_local_directory(&str);

    this->recursive_watch(&dir);
  }
  else if(command.Compare("FILE ",5) == 0)
  {
    BString path, dirpath, partial_path;
    BPath *bpath;
    int32 last_space = command.FindLast(" ");
    command.CopyInto(path,5,last_space - 5);

    path.CopyInto(dirpath,0,path.FindLast("/"));

    create_local_directory(&dirpath);
    //TODO fix watching new dirs
    bpath = new BPath(db_to_local_filepath(path.String()).String());
    BEntry new_file = BEntry(bpath->Path());
    if(new_file.InitCheck() && new_file.Exists()) {
      this->new_paths.AddItem((void*)bpath);
    } else {
      this->edited_paths.AddItem((void*)bpath);
    }

    printf("create a file at |%s|\n",path.String());
    char *argv[3];
    argv[0] = "db_get.py";
    char not_const1[path.CountChars() + 1];
    strcpy(not_const1,path.String());
    argv[1] = not_const1;
    BString tmp = db_to_local_filepath(path.String());
    char not_const2[tmp.CountChars() + 1]; //plus one for null
    strcpy(not_const2,tmp.String());
    argv[2] = not_const2;

    //create/update file
    //potential problem: takes awhile to do this step
    // having watching for dir turned off is risky.    
    BString * b = run_python_script(argv,3);
    delete b;

    //start watching the new/updated file
    node_ref nref;
    new_file = BEntry(db_to_local_filepath(path.String()).String());
    new_file.GetNodeRef(&nref);
    status_t err = watch_node(&nref,B_WATCH_STAT,be_app_messenger);

    BString parent_rev;
    command.CopyInto(parent_rev,last_space + 1, command.CountChars() - (last_space+1));
    BNode node = BNode(db_to_local_filepath(path.String()).String());
    set_parent_rev(&node,&parent_rev);
  }
  else if(command.Compare("FOLDER ",7) == 0)
  {
    BString path;
    command.CopyInto(path,7,command.FindLast(" ") - 7);

    //ignore the creation message
    BPath bpath = BPath(db_to_local_filepath(path.String()).String());
    BPath *actually_exists = find_existing_subpath(&bpath);
    this->new_paths.AddItem((void*)actually_exists);

    //create all nescessary dirs in path
    printf("create a folder at |%s|\n", path.String());
    create_local_directory(&path);

    //start watching the new dir
    BDirectory existing_dir = BDirectory(actually_exists->Path());
    recursive_watch(&existing_dir);
  }
  else if(command.Compare("REMOVE ",7) == 0)
  {
    //TODO: deal with Dropbox file paths being case-insensitive
    //which here means all lower case
    BString path;
    command.CopyInto(path,7,command.Length() - 7);

    const char * pathstr = db_to_local_filepath(path.String()).String();
    BPath *bpath = new BPath(pathstr);
    //TODO: check if it exists...
    this->removed_paths.AddItem((void*)bpath);

    printf("Remove whatever is at |%s|\n", pathstr);

    BEntry entry = BEntry(pathstr);
    status_t err = entry.Remove();
    if(err != B_OK)
      printf("Removal error: %s\n", strerror(err));
  }
  else
  {
    printf("Did not recognize command.\n");
    return B_ERROR;
  }
  return B_OK;
}
コード例 #9
0
ファイル: Printer.cpp プロジェクト: AmirAbrams/haiku
status_t
BPrinter::SetTo(const node_ref& nodeRef)
{
	SetTo(BDirectory(&nodeRef));
	return InitCheck();
}
コード例 #10
0
ファイル: InfoBox.cpp プロジェクト: carriercomm/Helios
void InfoBox::UpdateSizes() {
	float	display_size=0;	// Bytes
	float	display_time=0;	// Seconds
	char	bytes[21];		// ex: "kB"
	char	seconds[21];		// ex: "73m12.2s"
	char	temp[12];

	display_size=GetCDSize();
	display_time=(2352.0F*display_size/2048.0F)/176400.0F;
	
	// calculate playing time
	int min=(int)(display_time/60.0F);
	float sec=display_time-(min*60.0);
	sprintf(seconds, "%dm%s%0.1fs", min, (sec<10?"0":""), sec);	
	
	// calculate Bytes/kBytes/...
	sprintf(bytes, "B");	
	if (display_size>1024) {
		display_size/=1024.0F;
		sprintf(bytes, "kB");
	}
	if (display_size>1024) {
		display_size/=1024.0F;
		sprintf(bytes, "MB");
	}
	if (display_size>1024) {
		display_size/=1024.0F;
		sprintf(bytes, "GB");
	}
	if (display_size>1024) {
		display_size/=1024.0F;
		sprintf(bytes, "TB");
	}
	if (display_size>1024) {
		display_size/=1024.0F;
		sprintf(bytes, "EB");
	}
	sprintf(bytes, "%0.1f%s", display_size, strdup(bytes));

	Window()->Lock();
	switch(((Application1 *)be_app)->window1->view1->CDType()) {
		case DVDVIDEO_INDEX: {
			levelSB->SetMaxValue(2146500.0F);	// 477 minutes/2146500 sectors
			break;
		}
		default: {
			levelSB->SetMaxValue( (((Application1 *)be_app)->heliosCV->IsOverburning()?405000.0F:360000.0F));
			break;
		}
	}


	levelSB->Invalidate();
	levelSB->Update(-levelSB->CurrentValue()); 	// reset bar
	levelSB->Update((float)cd_size/2048.0F);

	levelSB->SetTrailingText(seconds);

	switch(((Application1 *)be_app)->window1->view1->CDType()) {
		case DATACD_INDEX: {
			levelSB->SetTrailingText(bytes);
			break;
		}
		case AUDIOCD_INDEX: {
			levelSB->SetTrailingText(seconds);
			break;
		}
		case CDEXTRA_INDEX: {
			levelSB->SetTrailingText(seconds);
			break;
		}
		case BOOTABLECD_INDEX: {
			levelSB->SetTrailingText(bytes);
			break;
		}
		case DVDVIDEO_INDEX: {
			levelSB->SetTrailingText(bytes);
			break;
		}
	}

	DrawWarningBitmap();

	folders=0;
	files=0;
	GetFolder(BDirectory(((Application1 *)be_app)->base_folder.String()));
	sprintf(temp,"%d",files);
	filecounterSV->SetText(temp);
	sprintf(temp,"%d",folders);
	foldercounterSV->SetText(temp);
	Window()->Unlock();
	return;


/*

	BString 	str="";
	char		str2[32];
	char 		*s="";
	char		temp[10];
	size_t 		u, disp_size;
	bool		gigabyte=false;

	Window()->Lock();
	//levelSB->SetBarColor((rgb_color){50, 150, 255});

//	stringview5->SetHighColor(0,0,0,255);
//	stringview10->SetHighColor(0,0,0,255);

	float r=(size_t)(((size_t)cd_size-((size_t)((float)cd_size/1048576.0F))*1048576.0F)/10485.76F);
	if (r<10) s="0"; else s="";
	
	//
	// TODO: ADD DVD SUPPORT!!!
	//
	if (((Application1 *)be_app)->window1->view1->CDType()==DVDVIDEO_INDEX)
		levelSB->SetMaxValue( 477.0F*60.0F);
	else
		levelSB->SetMaxValue( (((Application1 *)be_app)->heliosCV->IsOverburning()?91.0F:80.0F)*60.0F);
	levelSB->Update(-levelSB->CurrentValue());
	levelSB->Update((double)cd_size/153600.0F);

	DrawWarningBitmap();
	disp_size=cd_size;
	if ((disp_size/1048576)>1024) {
		disp_size/=1024;
		gigabyte=true;
	}

	float Size=disp_size;
	
	
	if ((((Application1 *)be_app)->window1->view1->CDType()==AUDIOCD_INDEX) ||
		(((Application1 *)be_app)->window1->view1->CDType()==CDEXTRA_INDEX)) {
		int min;
		float sec;
		
		min=(int)((float)disp_size/(153600.0F*60.0F));
		sec=((((float)disp_size)/(153600.0F))-((float)min*60.0F));
		//frm=(int)((((((float)cd_size)/(153600.0F))-(((float)min)*60.0F))-(((float)sec)))*75.0F+0.5F   );
		sprintf(str2, "%2.2d:%s%2.2f", min, ((sec<10.0F)?"0":""), sec);
		//str <<  min << ":" << (sec<10?"0":"") << sec << "." << (frm<10?"0":"") << frm;
	} else
		sprintf(str2, "%2.2f%s", (float)(Size/1048576), (gigabyte ? "GB" : "MB"));
		//str << (size_t)(cd_size/1048576) << "." << s << r << (gigabyte ? "GB" : "MB");
//	stringview5->SetText(str.String());
	levelSB->SetTrailingText(str2);
	

	r=(1.1484375F*(float)disp_size);

	if ((size_t)(r/176400)>4440) {	// grösser als 74m
//		levelSB->SetBarColor((rgb_color){180, 100, 120});
//		stringview5->SetHighColor(100,0,0,255);
//		stringview10->SetHighColor(100,0,0,255);
	}
	if ((size_t)(r/176400)>4800) {	// grösser als 80m
//		levelSB->SetBarColor((rgb_color){230, 60, 90});
//		stringview5->SetHighColor(150,0,0,255);
//		stringview10->SetHighColor(150,0,0,255);
	}
	if ((size_t)(r/176400)>5400) {	// grösser als 91m
//		levelSB->SetBarColor((rgb_color){255, 30, 60});
//		stringview5->SetHighColor(200,0,0,255);
//		stringview10->SetHighColor(200,0,0,255);
	}
	
	r=(float)(r/(176400.0F*60.0F));
	u=(size_t)((2352*disp_size/(2048*176400))-(r*60));
	if (u<10) s="0"; else s="";
	str="";
	str << (size_t)r << "m " << s << u << "s";
	stringview10->SetText(str.String());




	off_t size2=disp_size;
	if (((Application1 *)be_app)->heliosCV->IsFixating()) size2+=13824000;
	r=(2352*(size_t)size2/(2048*176400*(size_t)(((Application1 *)be_app)->heliosCV->GetWriterSpeed())));
	str="";
	r+=10; // 10 Sekunden Wartezeit von cdrecord
	r+=10; // und 10 sekunden wartezeit für spinup/spindown
	r+=10; // und dann nochmal 10 sekunden, für alle fälle...
	u=r-60*(size_t)(r/60);
	s="";
	
	if (u<10) s="0"; else s="";
	str << (off_t)(r/60) << "m " << s << (off_t)u << "s";
	stringview6->SetText(str.String());

	folders=0;
	files=0;
	GetFolder(BDirectory(((Application1 *)be_app)->base_folder.String()));
	sprintf(temp,"%d",files);
	filecounterSV->SetText(temp);
	sprintf(temp,"%d",folders);
	foldercounterSV->SetText(temp);

	Window()->Unlock();*/

}
コード例 #11
0
ファイル: HListView.cpp プロジェクト: kallisti5/beget
/***********************************************************
 * MessageReceived
 ***********************************************************/
void
HListView::MessageReceived(BMessage* message) {
	switch (message->what) {
		case M_PASS_MSG: {
				HListItem* item;
				if (message->FindPointer("pointer", (void**)&item) == B_OK) {
					item->SetLoginAndPassword(message->FindString("login"),
											  message->FindString("password"));
					item->Stop();
					item->Start();
				}
				break;
			}
		case B_NODE_MONITOR: {
				int32 opcode;
				if (message->FindInt32("opcode", &opcode) == B_OK) {
					//message->PrintToStream();
					switch (opcode) {
						case B_ENTRY_REMOVED: {
								node_ref nref;
								message->FindInt64("node", &nref.node);
								message->FindInt32("device", &nref.device);
								GoodbyeFile(nref);
								break;
							}
						case B_ENTRY_MOVED: {
								node_ref nref;
								node_ref from_directory;
								node_ref to_directory;
								message->FindInt64("from directory", &from_directory.node);
								message->FindInt64("to directory", &to_directory.node);
								if (from_directory.node == to_directory.node)
									break;

								message->FindInt64("node", &nref.node);
								message->FindInt32("device", &nref.device);

								const char* folder;
								((HApp*)be_app)->Prefs()->GetData("option", &folder);
								BString path = "";
								char* p = strstr(folder, "-P ");
								p += 3;
								while (*p) {
									if (*p == '\0' || *p == ' ')
										break;
									path << *p++;
								}

								node_ref folder_nref;
								BDirectory(path.String()).GetNodeRef(&folder_nref);

								if (from_directory.node == folder_nref.node)
									GoodbyeFile(nref);

								break;
							}
					}
				}
				break;
			}
		default:
			ColumnListView::MessageReceived(message);
	}
}