How do you handle "~" in a path string with dart -


i'm unaware on how make "~" expand using path. expect using path functions, directory/file class automatically handle it.

import "dart:io"; import 'package:path/path.dart';  void main() {   print(absolute("~"));   var d = new directory("~");   print(d.absolute.path); } 

prints

/private/tmp/dummy/dummy/bin/~ /private/tmp/dummy/dummy/bin/~ 

this depends on situation. in example can use following code.

import "dart:io"; import "package:file_utils/file_utils.dart";  void main() {   var home = filepath.expand("~/music");   var dir = new directory(home);   print(dir.absolute.path); } 

if want find files can use code.

import "package:file_utils/file_utils.dart";  void main() {   var songs = fileutils.glob("~/music/*{.mp3,.flac}");   for(var song in songs) {     print(song);   } } 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -