Changeset 1189
- Timestamp:
- 12/25/07 19:20:13 (8 months ago)
- Files:
-
- trunk/build/vfs/package.php (modified) (1 diff)
- trunk/src/main/php/org/stubbles/vfs/vfsStream.php (modified) (1 diff)
- trunk/src/main/php/org/stubbles/vfs/vfsStreamWrapper.php (modified) (6 diffs)
- trunk/src/test/php/org/stubbles/vfs/vfsStreamTestCase.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/build/vfs/package.php
r1188 r1189 41 41 - moved vfsStreamWrapper::PROTOCOL to vfsStream::SCHEME 42 42 - added new vfsStream::url() method to assist in creating correct vfsStream urls 43 - added vfsStream::path() method as opposite to vfsStream::url() 43 44 - a call to vfsStreamWrapper::register() will now reset the root to null (implemented because of a hint by David Zülke) 44 45 EOT; trunk/src/main/php/org/stubbles/vfs/vfsStream.php
r1183 r1189 23 23 * prepends the scheme to the given URL 24 24 * 25 * @param string $path 26 * @return string 27 */ 28 public static function url($path) 29 { 30 return self::SCHEME . '://' . str_replace(DIRECTORY_SEPARATOR, '/', $path); 31 } 32 33 /** 34 * restores the path from the url 35 * 25 36 * @param string $url 26 37 * @return string 27 38 */ 28 public static function url($url)39 public static function path($url) 29 40 { 30 return self::SCHEME . '://' . $url; 41 $path = substr($url, strlen(self::SCHEME . '://')); 42 $path = str_replace(DIRECTORY_SEPARATOR, '/', $path); 43 return $path; 31 44 } 32 45 } trunk/src/main/php/org/stubbles/vfs/vfsStreamWrapper.php
r1188 r1189 87 87 88 88 /** 89 * helper method to parse the path90 *91 * @param string $path92 * @return string93 */94 protected static function parsePath($path)95 {96 $path = substr($path, strlen(vfsStream::SCHEME . '://'));97 $path = str_replace(DIRECTORY_SEPARATOR, '/', $path);98 return $path;99 }100 101 /**102 89 * open the stream 103 90 * … … 115 102 } 116 103 117 $path = self::parsePath($path);104 $path = vfsStream::path($path); 118 105 if (self::$root->getName() === $path) { 119 106 $this->content = self::$root; … … 243 230 } 244 231 245 $realPath = self::parsePath($path);232 $realPath = vfsStream::path($path); 246 233 if (self::$root->getName() === $realPath) { 247 234 // delete root? very brave. :) … … 295 282 } 296 283 297 $path = self::parsePath($path);284 $path = vfsStream::path($path); 298 285 $lastSlashPos = strrpos($path, '/'); 299 286 $recursive = ((STREAM_MKDIR_RECURSIVE & $options) !== 0) ? (true) : (false); … … 378 365 } 379 366 380 $path = self::parsePath($path);367 $path = vfsStream::path($path); 381 368 if (self::$root->getName() === $path) { 382 369 $this->dir = self::$root; … … 442 429 } 443 430 444 $path = self::parsePath($path);431 $path = vfsStream::path($path); 445 432 if (self::$root->getName() === $path) { 446 433 $content = self::$root; trunk/src/test/php/org/stubbles/vfs/vfsStreamTestCase.php
r1183 r1189 17 17 class vfsStreamTestCase extends UnitTestCase 18 18 { 19 20 19 /** 21 * assure that a url builderworks correct20 * assure that path2url conversion works correct 22 21 */ 23 22 public function testURL() … … 25 24 $this->assertEqual('vfs://foo', vfsStream::url('foo')); 26 25 $this->assertEqual('vfs://foo/bar.baz', vfsStream::url('foo/bar.baz')); 26 $this->assertEqual('vfs://foo/bar.baz', vfsStream::url('foo\bar.baz')); 27 } 28 29 /** 30 * assure that url2path conversion works correct 31 */ 32 public function testPath() 33 { 34 $this->assertEqual('foo', vfsStream::path('vfs://foo')); 35 $this->assertEqual('foo/bar.baz', vfsStream::path('vfs://foo/bar.baz')); 36 $this->assertEqual('foo/bar.baz', vfsStream::path('vfs://foo\bar.baz')); 27 37 } 28 38 }
