겸손한 개발을 위한 자양분

앞서
WebSVN 에서 특정 저장소에 PREFIX 를 설정하여,
나타나지 않도록 하게 하였었다.

특정 저장소 리스트 숨기는 방법 보러가기

업무를 진행하다보니,
이번에는 공개된 저장소에서도 특정 폴더를
나타나지 않게 할 필요성이 있게 되었다.

WebSVN 은 저장소와 폴더(파일)의 개념이 독립적이기 때문에
수정 위치가 다르다.

다음과 같이 설정하여,
 "_preserve_" 라는 문자열로 시작되는 폴더를 숨길 수 있다.

< WebSVN \ listing.php >

function showDirFiles($svnrep, $subs, $level, $limit, $rev, $listing, $index, $treeview = true)
{
   global $rep, $passrev, $showchanged, $config, $lang;
   $path = "";
   if (!$treeview)
      $level = $limit;
   for ($n = 0; $n <= $level; $n++)
   {
      $path .= $subs[$n]."/";
   }
   $contents = $svnrep->dirContents($path, $rev);
   // List each file in the current directory
   $loop = 0;
   $last_index = 0;
   $openDir = false;
   $fullaccess = $rep->hasReadAccess($path, false);
  
   foreach($contents as $file)
   {
      $isDir = ($file{strlen($file) - 1} == "/"?1:0);
      $access = false;
      if( $isDir                              &&
          strncmp($file,"_preserve_",10) == 0 )
         continue;
      if ($isDir)
      {
         if ($rep->hasReadAccess($path.$file, true))

 ...
붉은색 코드가 추가된 부분이다.

만약, 폴더 뿐만이 아니라 파일까지 숨기고 싶다면,
위 코드 대신 아래의 코드를 삽입하면 된다.
      if( strncmp($file,"_preserve_",10) == 0 )
         continue;

마찬가지로,
특정 헤더에 설정값을 받도록 할 수 있겠지만,
귀차니즘...

끝!