@@ -39,7 +39,7 @@ pub struct Pathname {
39
39
40
40
impl Pathname {
41
41
pub fn new ( path : & str ) -> Pathname {
42
- let arguments = [ RString :: new ( path) . to_any_object ( ) ] ;
42
+ let arguments = [ RString :: new_utf8 ( path) . to_any_object ( ) ] ;
43
43
let instance = Class :: from_existing ( "Pathname" ) . new_instance ( Some ( & arguments) ) ;
44
44
45
45
Pathname { value : instance. value ( ) }
@@ -94,7 +94,7 @@ pub fn pn_add_trailing_separator(pth: MaybeString) -> RString {
94
94
let x = format ! ( "{}{}" , p. to_str( ) , "a" ) ;
95
95
match x. rsplit_terminator ( MAIN_SEPARATOR ) . next ( ) {
96
96
Some ( "a" ) => p,
97
- _ => RString :: new ( format ! ( "{}{}" , p. to_str( ) , MAIN_SEPARATOR ) . as_str ( ) )
97
+ _ => RString :: new_utf8 ( format ! ( "{}{}" , p. to_str( ) , MAIN_SEPARATOR ) . as_str ( ) )
98
98
}
99
99
}
100
100
@@ -105,11 +105,11 @@ pub fn pn_is_absolute(pth: MaybeString) -> Boolean {
105
105
// pub fn pn_ascend(){}
106
106
107
107
pub fn pn_basename ( pth : MaybeString , ext : MaybeString ) -> RString {
108
- RString :: new ( basename:: basename ( to_str ( & pth) , to_str ( & ext) ) )
108
+ RString :: new_utf8 ( basename:: basename ( to_str ( & pth) , to_str ( & ext) ) )
109
109
}
110
110
111
111
pub fn pn_children ( pth : MaybeString , with_dir : MaybeBoolean ) -> Result < AnyObject , Exception > {
112
- let path = pth. unwrap_or ( RString :: new ( "." ) ) ;
112
+ let path = pth. unwrap_or ( RString :: new_utf8 ( "." ) ) ;
113
113
let path = path. to_str ( ) ;
114
114
115
115
if let Ok ( entries) = fs:: read_dir ( path) {
@@ -122,12 +122,12 @@ pub fn pn_children(pth: MaybeString, with_dir: MaybeBoolean) -> Result<AnyObject
122
122
for entry in entries {
123
123
if with_directory {
124
124
match entry {
125
- Ok ( v) => { arr. push ( RString :: new ( v. path ( ) . to_str ( ) . unwrap ( ) ) ) ; } ,
125
+ Ok ( v) => { arr. push ( RString :: new_utf8 ( v. path ( ) . to_str ( ) . unwrap ( ) ) ) ; } ,
126
126
_ => { }
127
127
} ;
128
128
} else {
129
129
match entry {
130
- Ok ( v) => { arr. push ( RString :: new ( v. file_name ( ) . to_str ( ) . unwrap ( ) ) ) ; } ,
130
+ Ok ( v) => { arr. push ( RString :: new_utf8 ( v. file_name ( ) . to_str ( ) . unwrap ( ) ) ) ; } ,
131
131
_ => { }
132
132
} ;
133
133
}
@@ -173,8 +173,8 @@ pub fn pn_chop_basename(pth: MaybeString) -> AnyObject {
173
173
match chop_basename:: chop_basename ( to_str ( & pth) ) {
174
174
Some ( ( dirname, basename) ) => {
175
175
let mut arr = Array :: with_capacity ( 2 ) ;
176
- arr. push ( RString :: new ( & dirname) ) ;
177
- arr. push ( RString :: new ( & basename) ) ;
176
+ arr. push ( RString :: new_utf8 ( & dirname) ) ;
177
+ arr. push ( RString :: new_utf8 ( & basename) ) ;
178
178
arr. to_any_object ( )
179
179
} ,
180
180
None => NilClass :: new ( ) . to_any_object ( )
@@ -184,25 +184,25 @@ pub fn pn_chop_basename(pth: MaybeString) -> AnyObject {
184
184
// pub fn pn_cleanpath(pth: MaybeString){}
185
185
186
186
pub fn pn_cleanpath_aggressive ( pth : MaybeString ) -> RString {
187
- RString :: new ( & cleanpath_aggressive:: cleanpath_aggressive ( to_str ( & pth) ) )
187
+ RString :: new_utf8 ( & cleanpath_aggressive:: cleanpath_aggressive ( to_str ( & pth) ) )
188
188
}
189
189
190
190
pub fn pn_cleanpath_conservative ( pth : MaybeString ) -> RString {
191
- RString :: new ( & cleanpath_conservative:: cleanpath_conservative ( to_str ( & pth) ) )
191
+ RString :: new_utf8 ( & cleanpath_conservative:: cleanpath_conservative ( to_str ( & pth) ) )
192
192
}
193
193
194
194
pub fn pn_del_trailing_separator ( pth : MaybeString ) -> RString {
195
195
{
196
196
let path = to_str ( & pth) ;
197
197
if path. is_empty ( ) {
198
- return RString :: new ( "/" ) ;
198
+ return RString :: new_utf8 ( "/" ) ;
199
199
}
200
200
let pos = match find_last_non_sep_pos ( path. as_bytes ( ) ) {
201
201
Some ( pos) => pos,
202
- None => return RString :: new ( "/" ) ,
202
+ None => return RString :: new_utf8 ( "/" ) ,
203
203
} ;
204
204
if pos != path. len ( ) - 1 {
205
- return RString :: new ( & path[ ..pos + 1 ] ) ;
205
+ return RString :: new_utf8 ( & path[ ..pos + 1 ] ) ;
206
206
}
207
207
}
208
208
pth. unwrap ( )
@@ -215,7 +215,7 @@ pub fn pn_is_directory(pth: MaybeString) -> Boolean {
215
215
}
216
216
217
217
pub fn pn_dirname ( pth : MaybeString ) -> RString {
218
- RString :: new ( dirname:: dirname ( to_str ( & pth) ) )
218
+ RString :: new_utf8 ( dirname:: dirname ( to_str ( & pth) ) )
219
219
}
220
220
221
221
// pub fn pn_each_child(){}
@@ -229,11 +229,11 @@ pub fn pn_entries(pth: MaybeString) -> Result<AnyObject, Exception> {
229
229
if let Ok ( files) = fs:: read_dir ( path) {
230
230
let mut arr = Array :: with_capacity ( files. size_hint ( ) . 1 . unwrap_or ( 0 ) + 2 ) ;
231
231
232
- arr. push ( RString :: new ( "." ) ) ;
233
- arr. push ( RString :: new ( ".." ) ) ;
232
+ arr. push ( RString :: new_utf8 ( "." ) ) ;
233
+ arr. push ( RString :: new_utf8 ( ".." ) ) ;
234
234
235
235
for file in files {
236
- arr. push ( RString :: new ( file. unwrap ( ) . file_name ( ) . to_str ( ) . unwrap ( ) ) ) ;
236
+ arr. push ( RString :: new_utf8 ( file. unwrap ( ) . file_name ( ) . to_str ( ) . unwrap ( ) ) ) ;
237
237
}
238
238
239
239
Ok ( arr. to_any_object ( ) )
@@ -263,7 +263,7 @@ pub fn pn_entries_compat(pth: MaybeString) -> Result<AnyObject, Exception> {
263
263
}
264
264
265
265
pub fn pn_extname ( pth : MaybeString ) -> RString {
266
- RString :: new ( extname:: extname ( to_str ( & pth) ) )
266
+ RString :: new_utf8 ( extname:: extname ( to_str ( & pth) ) )
267
267
}
268
268
269
269
// pub fn pn_find(pth: MaybeString, ignore_error: Boolean){}
@@ -298,7 +298,7 @@ pub fn pn_join(args: MaybeArray) -> AnyObject {
298
298
// pub fn pn_parent(pth: MaybeString){}
299
299
300
300
pub fn pn_plus ( pth1 : MaybeString , pth2 : MaybeString ) -> RString {
301
- RString :: new ( & plus:: plus_paths ( to_str ( & pth1) , to_str ( & pth2) ) )
301
+ RString :: new_utf8 ( & plus:: plus_paths ( to_str ( & pth1) , to_str ( & pth2) ) )
302
302
}
303
303
304
304
// pub fn pn_prepend_prefix(prefix: MaybeString, relpath: MaybeString){}
0 commit comments