| Index: runtime/bin/directory.h
 | 
| diff --git a/runtime/bin/directory.h b/runtime/bin/directory.h
 | 
| index 9402031054dd565791efe8d23b37cd1744f21b0e..e37aa769dc03741aa435f18dc1ab3d8d871a52d0 100644
 | 
| --- a/runtime/bin/directory.h
 | 
| +++ b/runtime/bin/directory.h
 | 
| @@ -25,9 +25,7 @@ enum ListType {
 | 
|  class PathBuffer {
 | 
|   public:
 | 
|    PathBuffer();
 | 
| -  ~PathBuffer() {
 | 
| -    free(data_);
 | 
| -  }
 | 
| +  ~PathBuffer();
 | 
|  
 | 
|    bool Add(const char* name);
 | 
|    bool AddW(const wchar_t* name);
 | 
| @@ -35,15 +33,18 @@ class PathBuffer {
 | 
|    char* AsString() const;
 | 
|    wchar_t* AsStringW() const;
 | 
|  
 | 
| -  void Reset(int new_length);
 | 
| +  // Makes a scope allocated copy of the string.
 | 
| +  const char* AsScopedString() const;
 | 
| +
 | 
| +  void Reset(intptr_t new_length);
 | 
|  
 | 
| -  int length() const {
 | 
| +  intptr_t length() const {
 | 
|      return length_;
 | 
|    }
 | 
|  
 | 
|   private:
 | 
|    void* data_;
 | 
| -  int length_;
 | 
| +  intptr_t length_;
 | 
|  
 | 
|    DISALLOW_COPY_AND_ASSIGN(PathBuffer);
 | 
|  };
 | 
| @@ -112,10 +113,10 @@ class DirectoryListing {
 | 
|      }
 | 
|    }
 | 
|  
 | 
| -  virtual bool HandleDirectory(char* dir_name) = 0;
 | 
| -  virtual bool HandleFile(char* file_name) = 0;
 | 
| -  virtual bool HandleLink(char* link_name) = 0;
 | 
| -  virtual bool HandleError(const char* dir_name) = 0;
 | 
| +  virtual bool HandleDirectory(const char* dir_name) = 0;
 | 
| +  virtual bool HandleFile(const char* file_name) = 0;
 | 
| +  virtual bool HandleLink(const char* link_name) = 0;
 | 
| +  virtual bool HandleError() = 0;
 | 
|    virtual void HandleDone() {}
 | 
|  
 | 
|    void Push(DirectoryListingEntry* directory) {
 | 
| @@ -145,8 +146,8 @@ class DirectoryListing {
 | 
|      return follow_links_;
 | 
|    }
 | 
|  
 | 
| -  char* CurrentPath() {
 | 
| -    return path_buffer_.AsString();
 | 
| +  const char* CurrentPath() {
 | 
| +    return path_buffer_.AsScopedString();
 | 
|    }
 | 
|  
 | 
|    PathBuffer& path_buffer() {
 | 
| @@ -182,10 +183,10 @@ class AsyncDirectoryListing : public DirectoryListing {
 | 
|        : DirectoryListing(dir_name, recursive, follow_links) {}
 | 
|  
 | 
|    virtual ~AsyncDirectoryListing() {}
 | 
| -  virtual bool HandleDirectory(char* dir_name);
 | 
| -  virtual bool HandleFile(char* file_name);
 | 
| -  virtual bool HandleLink(char* file_name);
 | 
| -  virtual bool HandleError(const char* dir_name);
 | 
| +  virtual bool HandleDirectory(const char* dir_name);
 | 
| +  virtual bool HandleFile(const char* file_name);
 | 
| +  virtual bool HandleLink(const char* file_name);
 | 
| +  virtual bool HandleError();
 | 
|    virtual void HandleDone();
 | 
|  
 | 
|    void SetArray(CObjectArray* array, intptr_t length) {
 | 
| @@ -200,7 +201,7 @@ class AsyncDirectoryListing : public DirectoryListing {
 | 
|    }
 | 
|  
 | 
|   private:
 | 
| -  bool AddFileSystemEntityToResponse(Response response, char* arg);
 | 
| +  bool AddFileSystemEntityToResponse(Response response, const char* arg);
 | 
|    CObjectArray* array_;
 | 
|    intptr_t index_;
 | 
|    intptr_t length_;
 | 
| @@ -226,10 +227,10 @@ class SyncDirectoryListing: public DirectoryListing {
 | 
|          DartUtils::GetDartType(DartUtils::kIOLibURL, "Link");
 | 
|    }
 | 
|    virtual ~SyncDirectoryListing() {}
 | 
| -  virtual bool HandleDirectory(char* dir_name);
 | 
| -  virtual bool HandleFile(char* file_name);
 | 
| -  virtual bool HandleLink(char* file_name);
 | 
| -  virtual bool HandleError(const char* dir_name);
 | 
| +  virtual bool HandleDirectory(const char* dir_name);
 | 
| +  virtual bool HandleFile(const char* file_name);
 | 
| +  virtual bool HandleLink(const char* file_name);
 | 
| +  virtual bool HandleError();
 | 
|  
 | 
|   private:
 | 
|    Dart_Handle results_;
 | 
| @@ -252,11 +253,18 @@ class Directory {
 | 
|  
 | 
|    static void List(DirectoryListing* listing);
 | 
|    static ExistsResult Exists(const char* path);
 | 
| -  static char* Current();
 | 
| +
 | 
| +  // Returns the current working directory. The caller must call
 | 
| +  // free() on the result.
 | 
| +  static char* CurrentNoScope();
 | 
| +
 | 
| +  // Returns the current working directory. The returned string is allocated
 | 
| +  // with Dart_ScopeAllocate(). It lasts only as long as the current API scope.
 | 
| +  static const char* Current();
 | 
| +  static const char* SystemTemp();
 | 
| +  static const char* CreateTemp(const char* path);
 | 
|    static bool SetCurrent(const char* path);
 | 
|    static bool Create(const char* path);
 | 
| -  static char* SystemTemp();
 | 
| -  static char* CreateTemp(const char* path);
 | 
|    static bool Delete(const char* path, bool recursive);
 | 
|    static bool Rename(const char* path, const char* new_path);
 | 
|  
 | 
| 
 |