Системное программирование в UNIX средствами Free Pascal


           

не удалось изменить права доступа


  st:stat;

  res:integer;

  polniypath:array [0..2000] of char;

  ch:string;

  n,i:byte;

begin

  flag:=true;

  d:=opendir(name);

  if d=nil then

  begin

    writeln('Ошибка открытия каталога ',name);

    exit;

  end;

  el:=readdir(d);

  while el<>nil do

  begin

    polniypath:=name;

    if strcomp(name,'/')=0 then

      strcat(polniypath,el^.name)

    else

    begin

      if name[strlen(name)-1]<>'/' then

          strcat(polniypath,'/');

      strcat(polniypath,el^.name);

    end;

   

    if not fstat(pchar(polniypath),st) then

        writeln('Ошибка вызова stat для ',polniypath)

    else

    begin

           //if not (gettype(st.mode) = 'd') then

      if not chmod(pchar(polniypath),prava) then

        writeln('Ошибка установки прав доступа ',prava,' для ',polniypath);

    end;

    el:=readdir(d);

  end;

  closedir(d);

 

  d:=opendir(name);

  el:=readdir(d);

  while el<>nil do

  begin

    polniypath:=name;

    if strcomp(name,'/')=0 then

      strcat(polniypath,el^.name)

    else

    begin

      if name[strlen(name)-1]<>'/' then

        strcat(polniypath,'/');

      strcat(polniypath,el^.name);

    end;

    if not fstat(pchar(polniypath),st) then

      writeln('Ошибка вызова stat для ',polniypath)

    else

    begin

      if (gettype(st.mode)='d') and

         (strcomp(el^.name,'.')<>0) and

         (strcomp(el^.name,'..')<>0) then

      begin

        writeln('Переход в каталог ',polniypath);     

        if not obhod(prava,polniypath) then

          flag:=false;

      end;

    end;

    el:=readdir(d);

  end;

  closedir(d);

  if not flag then

    writeln(' У каталога ',name, ' не удалось изменить права доступа ');

//  writeln('Для каталога ',name, ' получен ',flag);

  obhod:=flag;

end;

var

  name:array [0..2000] of char;

  prava,i:integer;

  ch:string;

begin

  if paramcount<>2 then

  begin

    writeln('Используйте: ',paramstr(0),' права_доступа файл/каталог');


Содержание  Назад  Вперед





Forekc.ru
Рефераты, дипломы, курсовые, выпускные и квалификационные работы, диссертации, учебники, учебные пособия, лекции, методические пособия и рекомендации, программы и курсы обучения, публикации из профильных изданий