@@ -913,39 +913,42 @@ public function ls(string $path, array $flags = []) : array
913913 * Checks if a path exists and is a file.
914914 *
915915 * @param string $path Path to check.
916+ * @param array $flags Additional flags (e.g. ['metadata' => true]).
916917 *
917918 * @return object Object with 'exists' (bool), 'details' (object|array), and 'error' (string|\Exception) properties.
918919 */
919- public function is_file (string $ path ) : object
920+ public function is_file (string $ path, array $ flags = [] ) : object
920921 {
921- return $ this ->exists ($ path , 'file ' );
922+ return $ this ->exists ($ path , 'file ' , $ flags );
922923 }
923924
924925 /**
925926 * Checks if a path exists and is a directory.
926927 *
927928 * @param string $path Path to check.
929+ * @param array $flags Additional flags.
928930 *
929931 * @return object Object with 'exists' (bool), 'details' (object|array), and 'error' (string|\Exception) properties.
930932 */
931- public function is_dir (string $ path ) : object
933+ public function is_dir (string $ path, array $ flags = [] ) : object
932934 {
933- return $ this ->exists ($ path , 'dir ' );
935+ return $ this ->exists ($ path , 'dir ' , $ flags );
934936 }
935937
936938 /**
937939 * Checks if a path exists and is of the specified type ('file' or 'dir').
938940 * This method lists the parent directory and then filters for the specific item.
939941 *
940- * @param string $path The path to check.
941- * @param string $type The type to check for ('file' or 'dir').
942+ * @param string $path The path to check.
943+ * @param string $type The type to check for ('file' or 'dir').
944+ * @param array $flags Additional flags for the ls operation.
942945 *
943946 * @return object An object with properties:
944947 * - bool 'exists': True if the item exists and matches the type.
945948 * - mixed 'details': The item's details from 'lsjson' if it exists, else empty array.
946949 * - mixed 'error': The Exception object if an error occurred during 'ls', else empty string.
947950 */
948- public function exists (string $ path , string $ type ) : object
951+ public function exists (string $ path , string $ type, array $ flags = [] ) : object
949952 {
950953 $ dirname = dirname ($ path );
951954 // If dirname is '.', it means the path is at the remote's root.
@@ -956,7 +959,7 @@ public function exists(string $path, string $type) : object
956959 $ basename = basename ($ path );
957960
958961 try {
959- $ listing = $ this ->ls ($ dirname ); // List parent directory contents.
962+ $ listing = $ this ->ls ($ dirname, $ flags ); // List parent directory contents.
960963 $ found_item = array_filter ($ listing , static fn ($ item ) => isset ($ item ->Name ) && $ item ->Name === $ basename &&
961964 isset ($ item ->IsDir ) && $ item ->IsDir === ($ type === 'dir ' ),
962965 );
0 commit comments