Setting permissions in existing files?



Ok, I'm using gnomemm. I have a dialogue with checkboxes that are filled
according to a given files' permissions. What I currently have is at
http://svn.berlios.de/viewcvs/darimasen/trunk/src/iconmodes.cpp?rev=22 ,
if more details are needed.

Now how do I change the permissions of a file? All the tests in the code
below work, except for the try{} section. I am not finding anything to
take the new Gnome::Vfs::FilePermissions.

What can I do?

-Sud.




------My Code------

void
DaIconModes::SetPermissionsDialogue::apply(Glib::RefPtr<Gnome::Vfs::FileInfo>
info){


  Gnome::Vfs::FilePermissions permissions;
  //make sure I've got the stuff that doesn't change
  permissions = info->get_permissions();


  if(u_r->get_active()){
    std::cout << "+u_r ";
  }else{
    std::cout << "-u_r ";
  }
  if(u_w->get_active()){
    std::cout << "+u_w ";
  }else{
    std::cout << "-u_w ";
  }
  if(u_x->get_active()){
    std::cout << "+u_x ";
  }else{
    std::cout << "-u_x ";
  }
    std::cout << "\n";
  if(g_r->get_active()){
    std::cout << "+g_r ";
  }else{
    std::cout << "-g_r ";
  }
  if(g_w->get_active()){
    std::cout << "+g_w ";
  }else{
    std::cout << "-g_w ";
  }
  if(g_x->get_active()){
    std::cout << "+g_x ";
  }else{
    std::cout << "-g_x ";
  }
    std::cout << "\n";
  if(o_r->get_active()){
(permissions & Gnome::Vfs::PERM_OTHER_READ) == 1;
    std::cout << "+o_r ";
  }else{
(permissions & Gnome::Vfs::PERM_OTHER_READ) == 0;
    std::cout << "-o_r ";
  }
  if(o_w->get_active()){
(permissions & Gnome::Vfs::PERM_OTHER_WRITE) == 1;
    std::cout << "+o_w ";
  }else{
(permissions & Gnome::Vfs::PERM_OTHER_WRITE) == 0;
    std::cout << "-o_w ";
  }
  if(o_x->get_active()){
(permissions & Gnome::Vfs::PERM_OTHER_EXEC) == 1;
    std::cout << "+o_x ";
  }else{
(permissions & Gnome::Vfs::PERM_OTHER_EXEC) == 0;
    std::cout << "-o_x ";
  }
    std::cout << "\n\n";


try{
Gnome::Vfs::Handle::set_file_info(fullPath + info->get_name(),
permissions, Gnome::Vfs::SET_FILE_INFO_PERMISSIONS);
}
  catch(const Gnome::Vfs::exception& ex){
std::cout << "Could not change permissions.\n";
}


hide();



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]