Roxen.git / server / modules / filesystems / filesystem.pike

version» Context lines:

Roxen.git/server/modules/filesystems/filesystem.pike:420:      //! Convert to filesystem encoding.   //!   //! @note   //! Note that the @expr{"iso-8859-1"@} encoding will perform   //! conversion to utf-8 for wide strings OSes other than NT.   string encode_path( string p )   {    if( path_encoding != "iso-8859-1" )    p = Locale.Charset.encoder( path_encoding )->feed( p )->drain(); - #ifndef __NT__ + #if !defined(__NT__) || constant(Stdio.__HAVE_UTF8_FS__)    if( String.width( p ) != 8 )    p = string_to_utf8( p ); - #else + #endif + #ifdef __NT__ +  // NB: stat() on NT doesn't like trailing slashes (cf [bug 76]).    while( strlen(p) && p[-1] == '/' )    p = p[..strlen(p)-2];   #endif    return p;   }      //! Convert from filesystem encoding.   string decode_path(string p)   { - #ifdef __NT__ + #if defined(__NT__) && !constant(Stdio.__HAVE_UTF8_FS__)    // The filesystem on NT uses wide characters.    return p;   #else    // While filesystems on other OSes typically are 8bit.    switch(lower_case(path_encoding)) {    case "iso-8859-1":    return p;    case "utf8": case "utf-8":    // NB: We assume that the filesystem will normalize    // the path as appropriate.    return Unicode.normalize(utf8_to_string(p), "NFC");    default:    return Charset.decoder(path_encoding)->feed(p)->drain();    } - #endif /* !__NT__ */ + #endif /* !__NT__ || Stdio.__HAVE_UTF8_FS__ */   }      string real_path(string f, RequestID id)   {    f = normalized_path + encode_path(f);    if (FILTER_INTERNAL_FILE(f, id)) return 0;   #ifdef __NT__    // These characters are apparently invalid in NTFS filenames.    if (f != replace(f, "*?|"/"", ({ "", "", "" }))) {    return 0;