2 +----------------------------------------------------------------------+
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-2014 Facebook, Inc. (http://www.facebook.com) |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 3.01 of the PHP license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | http://www.php.net/license/3_01.txt |
11 | If you did not receive a copy of the PHP license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
17 #include "hphp/runtime/base/glob-stream-wrapper.h"
19 #include "hphp/runtime/base/directory.h"
20 #include "hphp/runtime/ext/ext_file.h"
23 ///////////////////////////////////////////////////////////////////////////////
25 File
* GlobStreamWrapper::open(const String
& filename
,
29 // Can't open a glob as a file, it's meant to be opened as a directory
31 // if the function was called via FCallBuiltin, we'll get a bogus name as
32 // the stack frame will be wrong
33 ActRec
* ar
= g_vmContext
->getStackFrame();
34 const char* fn
= (ar
!= nullptr)
35 ? ar
->func()->name()->data()
36 : "OPTIMIZED_BUILTIN";
37 raise_warning("%s(%s): failed to open stream: "
38 "wrapper does not support stream open",
43 Directory
* GlobStreamWrapper::opendir(const String
& path
) {
44 const char* prefix
= "glob://";
45 const char* path_str
= path
.data();
46 int path_len
= path
.length();
48 // only accept paths with the glob:// prefix
49 if (strncmp(path_str
, prefix
, strlen(prefix
)) != 0) {
53 path_str
+= strlen(prefix
);
54 path_len
-= strlen(prefix
);
56 auto glob
= f_glob(String(path_str
, path_len
, CopyString
));
57 if (!glob
.isArray()) {
60 return NEWOBJ(ArrayDirectory
)(glob
.toArray());
63 ///////////////////////////////////////////////////////////////////////////////