@@ -337,9 +337,9 @@ pub fn dll_filename(base: &str) -> ~str {
337
337
format ! ( "{}{}{}" , consts:: DLL_PREFIX , base, consts:: DLL_SUFFIX )
338
338
}
339
339
340
- /// Optionally returns the filesystem path to the current executable which is
340
+ /// Optionally returns the filesystem path of the current executable which is
341
341
/// running. If any failure occurs, None is returned.
342
- pub fn self_exe_path ( ) -> Option < Path > {
342
+ pub fn self_exe_name ( ) -> Option < Path > {
343
343
344
344
#[ cfg( target_os = "freebsd" ) ]
345
345
fn load_self ( ) -> Option < ~[ u8 ] > {
@@ -402,7 +402,14 @@ pub fn self_exe_path() -> Option<Path> {
402
402
}
403
403
}
404
404
405
- load_self ( ) . and_then ( |path| Path :: new_opt ( path) . map ( |mut p| { p. pop ( ) ; p } ) )
405
+ load_self ( ) . and_then ( Path :: new_opt)
406
+ }
407
+
408
+ /// Optionally returns the filesystem path to the current executable which is
409
+ /// running. Like self_exe_name() but without the binary's name.
410
+ /// If any failure occurs, None is returned.
411
+ pub fn self_exe_path ( ) -> Option < Path > {
412
+ self_exe_name ( ) . map ( |mut p| { p. pop ( ) ; p } )
406
413
}
407
414
408
415
/**
@@ -1310,6 +1317,17 @@ mod tests {
1310
1317
assert_eq!(getenv(n), option::Some(s));
1311
1318
}
1312
1319
1320
+ #[test]
1321
+ fn test_self_exe_name() {
1322
+ let path = os::self_exe_name();
1323
+ assert!(path.is_some());
1324
+ let path = path.unwrap();
1325
+ debug!(" { : ?} ", path.clone());
1326
+
1327
+ // Hard to test this function
1328
+ assert!(path.is_absolute());
1329
+ }
1330
+
1313
1331
#[test]
1314
1332
fn test_self_exe_path() {
1315
1333
let path = os::self_exe_path();
0 commit comments