pike.git / lib / master.pike.in

version» Context lines:

pike.git/lib/master.pike.in:547:   //!   array(string) explode_path(string p)   {    array(string) r = EXPLODE_PATH(p);    if(r[0] == "" && sizeof(p))    r[0] = "/";    return r;   }      #if !constant(dirname) - //! Returns all but the last segment of a path. Some example inputs and - //! outputs: - //! - //! @xml{<matrix> - //! <r><c><b>Expression</b></c><c><b>Value</b></c></r> - //! <r><c>dirname("/a/b")</c><c>"/a"</c></r> - //! <r><c>dirname("/a/")</c><c>"/a"</c></r> - //! <r><c>dirname("/a")</c><c>"/"</c></r> - //! <r><c>dirname("/")</c><c>"/"</c></r> - //! <r><c>dirname("")</c><c>""</c></r> - //! </matrix>@} - //! - //! @seealso - //! @[basename()], @[explode_path()] +    string dirname(string x)   {    if(x=="") return "";    array(string) tmp = EXPLODE_PATH(x);    if (x[0] == '/' && sizeof(tmp) < 3) return "/";    return tmp[..<1]*"/";   }   #else /* dirname */   constant dirname = predef::dirname;   #endif /* !dirname */      #if !constant(basename) - //! Returns the last segment of a path. - //! - //! @seealso - //! @[dirname()], @[explode_path()] +    string basename(string x)   {    array(string) tmp=EXPLODE_PATH(x);    return tmp[-1];   #define BASENAME(X) (EXPLODE_PATH(X)[-1])   }   #else /* basename */   constant basename = predef::basename;   #define BASENAME(X) basename(X)   #endif /* !basename */