@@ -1234,6 +1234,52 @@ RL_API REBCNT RL_Decode_UTF8_Char(const REBYTE *str, REBCNT *len)
1234
1234
}
1235
1235
1236
1236
1237
+ /***********************************************************************
1238
+ **
1239
+ */ RL_API REBSER * RL_To_Local_Path (RXIARG * file , REBFLG full , REBFLG utf8 )
1240
+ /*
1241
+ ** Convert REBOL filename to a local filename.
1242
+ **
1243
+ ** Returns:
1244
+ ** A new series with the converted path or 0 on error.
1245
+ ** Arguments:
1246
+ ** file - Rebol file as an extension argument (series + index)
1247
+ ** full - prepend current directory
1248
+ ** utf8 - convert to UTF-8 if needed
1249
+ **
1250
+ ***********************************************************************/
1251
+ {
1252
+ REBSER * ser = file -> series ;
1253
+ REBLEN index = file -> index ;
1254
+
1255
+ if (!ser || index > SERIES_TAIL (ser )) return 0 ;
1256
+
1257
+ ser = To_Local_Path (SERIES_SKIP (ser , index ), SERIES_TAIL (ser )- index , !BYTE_SIZE (ser ), full );
1258
+ // To_Local_Path always returns REBUNI series
1259
+ if (ser && utf8 ) {
1260
+ ser = Encode_UTF8_String (SERIES_DATA (ser ), SERIES_TAIL (ser ), 1 , 0 );
1261
+ }
1262
+ return ser ;
1263
+ }
1264
+
1265
+ /***********************************************************************
1266
+ **
1267
+ */ RL_API REBSER * RL_To_Rebol_Path (void * src , REBCNT len , REBINT uni )
1268
+ /*
1269
+ ** Convert local filename to a REBOL filename.
1270
+ **
1271
+ ** Returns:
1272
+ ** A new series with the converted path or 0 on error.
1273
+ ** Arguments:
1274
+ ** ser - series as a REBYTE or REBUNI.
1275
+ ** len - number of source bytes consumed.
1276
+ ** uni - if series is REBYTE (0) or REBUNI (1)
1277
+ **
1278
+ ***********************************************************************/
1279
+ {
1280
+ return To_REBOL_Path (src , len , uni , 0 );
1281
+ }
1282
+
1237
1283
1238
1284
#include "reb-lib-lib.h"
1239
1285
0 commit comments