LTP GCOV extension - code coverage report
Current view: directory - src/cpp/dev/idlc/back - CodeUtils.cpp
Test: YAORB-0.2.info
Date: 2006-02-27 Instrumented lines: 30
Code covered: 53.3 % Executed lines: 16

       1                 : //==============================================================================
       2                 : // File <$/src/cpp/dev/idlc/back/CodeUtils.cpp>
       3                 : // This file is part of YaOrb : Yet Another Object Request Broker,
       4                 : // Copyright (c) 2000-2003, Marc Alff.
       5                 : //
       6                 : // This program is free software; you can redistribute it and/or
       7                 : // modify it under the terms of the GNU General Public License
       8                 : // as published by the Free Software Foundation; either version 2
       9                 : // of the License, or (at your option) any later version.
      10                 : //
      11                 : // This program is distributed in the hope that it will be useful,
      12                 : // but WITHOUT ANY WARRANTY; without even the implied warranty of
      13                 : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      14                 : // GNU General Public License for more details.
      15                 : //
      16                 : // You should have received a copy of the GNU General Public License
      17                 : // along with this program; if not, write to the Free Software
      18                 : // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
      19                 : //
      20                 : //==============================================================================
      21                 : 
      22                 : #include <sys/stat.h>
      23                 : #include <sys/types.h>
      24                 : 
      25                 : // Portability :
      26                 : #include "include/yaorb/config.h"
      27                 : #include "src/cpp/prod/port/port_stdc.h"
      28                 : 
      29                 : #include "src/cpp/dev/idlc/yyutils.h"
      30                 : #include "src/cpp/dev/idlc/back/CodeUtils.h"
      31                 : #include "src/cpp/prod/tool/StringTokenizer.h"
      32                 : 
      33                 : void
      34                 : CodeUtils::MkFullDir(
      35                 :    const String & dir,
      36               4 :    const String & path)
      37                 : {
      38               4 :    String dirPath = dir ;
      39               4 :    StringTokenizer parser(path, "/") ;
      40                 : 
      41              46 :    while( parser.hasMoreTokens() == true)
      42                 :    {
      43              42 :       dirPath += parser.nextToken() ;
      44              42 :       CodeUtils::MkDir(dirPath) ;
      45              42 :       dirPath += '/' ;
      46               0 :    }
      47                 : }
      48                 : 
      49                 : void
      50                 : CodeUtils::MkDir(
      51             250 :    const String & path)
      52                 : {
      53                 :    int rc = 0 ;
      54             250 :    struct stat buf = {0} ;
      55                 : 
      56             250 :    if (path.length() == 0)
      57                 :    {
      58             238 :       return ;
      59                 :    }
      60                 : 
      61             238 :    rc = stat(path, & buf) ;
      62                 : 
      63             238 :    if (rc != 0)
      64                 :    {
      65                 :       /* rwxr-xr-x */
      66                 :       mode_t mode = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH ;
      67               0 :       rc = mkdir(path, mode) ;
      68                 : 
      69               0 :       if (rc != 0)
      70                 :       {
      71               0 :          String error ;
      72               0 :          error = "Can not create directory <" ;
      73               0 :          error += path ;
      74               0 :          error += ">" ;
      75                 : 
      76               0 :          IDLCompileError(error) ;
      77                 :       }
      78                 :    }
      79                 :    else
      80                 :    {
      81             238 :       if ( ! S_ISDIR(buf.st_mode))
      82                 :       {
      83               0 :          String error ;
      84               0 :          error = "File <" ;
      85               0 :          error += path ;
      86               0 :          error += "> already exist and is not a directory." ;
      87                 : 
      88               0 :          IDLCompileError(error) ;
      89                 :       }
      90                 :    }
      91              33 : }

Generated by: LTP GCOV extension version 1.4