File: build/filename_util.ml (return to index)



Statistics:  
kind coverage
binding 3 / 3 (100 %)
sequence 0 / 0 (- %)
for 0 / 0 (- %)
if/then 4 / 5 (80 %)
try 0 / 0 (- %)
while 0 / 0 (- %)
match/function 5 / 6 (83 %)
kind coverage
class expression 0 / 0 (- %)
class initializer 0 / 0 (- %)
class method 0 / 0 (- %)
class value 0 / 0 (- %)
toplevel expression 0 / 0 (- %)
lazy operator 2 / 2 (100 %)



Source:

fold all unfold all
000001| (**
000002| This program is free software; you can redistribute it and / or modify
000003| it under the terms of the GNU General Public License as published by
000004| the Free Software Foundation; version 3 of the License.
000005|
000006| This program is distributed in the hope that it will be useful,
000007| but WITHOUT ANY WARRANTY; without even the implied warranty of
000008| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
000009| GNU General Public License for more details.
000010|
000011| Filename utilities 
000012|
000013| @author Tony BenBrahim < tony.benbrahim at gmail.com >
000014|
000015| *)
000016|
000017| (** 
000018| converts a relative filename and path into an absolute filename 
000019| @param dir relative of absolute path
000020| @param filename 
000021| @return absolute path of file
000022| *)
000023| let resolve_filename dir filename =
000024|   (*[20]*)let rec cleanup check ok =
000025|     (*[184]*)let right = Filename.basename check in
000026|     (*[184]*)let left = Filename.dirname check in
000027|     (*[184]*)if ((*[184]*)right ="." && (*[24]*)Filename.dirname left = left) then
000028|       (*[20]*)Filename.concat left ok
000029|     else
000030|       match right with
000031|       | "." -> (*[4]*)cleanup left ok
000032|       | ".." -> (*[2]*)cleanup (Filename.dirname left) ok
000033|       | "" -> (*[0]*)ok
000034|       | _ -> (*[158]*)cleanup left (if ok ="" then (*[20]*)right else (*[138]*)Filename.concat right ok)
000035|   in
000036|   (*[20]*)if Filename.is_relative filename then
000037|     (*[20]*)cleanup (Filename.concat dir filename) ""
000038|   else
000039|     (*[0]*)filename

Legend:
   some code - line containing no point
   some code - line containing only visited points
   some code - line containing only unvisited points
   some code - line containing both visited and unvisited points