From 0ed93d71b235ce80d240467d0fd53202f57d88e1 Mon Sep 17 00:00:00 2001 From: Jason Greene Date: Fri, 11 May 2001 01:47:46 +0000 Subject: [PATCH] @fstat() and stat() now return identical output by returning a numerical and @string indexed array (Jason) (Andrei's suggestion to still allow backwords compatibility.) --- ext/standard/file.c | 26 ++++++++++++++++++++++++++ ext/standard/filestat.c | 24 ++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/ext/standard/file.c b/ext/standard/file.c index 82bfa0eba7..28c6c3084b 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -1801,6 +1801,32 @@ PHP_NAMED_FUNCTION(php_if_fstat) array_init(return_value); + add_next_index_long(return_value, stat_sb.st_dev); + add_next_index_long(return_value, stat_sb.st_ino); + add_next_index_long(return_value, stat_sb.st_mode); + add_next_index_long(return_value, stat_sb.st_nlink); + add_next_index_long(return_value, stat_sb.st_uid); + add_next_index_long(return_value, stat_sb.st_gid); +#ifdef HAVE_ST_RDEV + add_next_index_long(return_value, stat_sb.st_rdev); +#else + add_next_index_long(return_value, -1); +#endif + add_next_index_long(return_value, stat_sb.st_size); + add_next_index_long(return_value, stat_sb.st_atime); + add_next_index_long(return_value, stat_sb.st_mtime); + add_next_index_long(return_value, stat_sb.st_ctime); +#ifdef HAVE_ST_BLKSIZE + add_next_index_long(return_value, stat_sb.st_blksize); +#else + add_next_index_long(return_value, -1); +#endif +#ifdef HAVE_ST_BLOCKS + add_next_index_long(return_value, stat_sb.st_blocks); +#else + add_next_index_long(return_value, -1); +#endif + /* Support string references as well as numerical*/ add_assoc_long ( return_value , "dev" , stat_sb.st_dev ); add_assoc_long ( return_value , "ino" , stat_sb.st_ino ); add_assoc_long ( return_value , "mode" , stat_sb.st_mode ); diff --git a/ext/standard/filestat.c b/ext/standard/filestat.c index 866403238e..49f8ddc3f3 100644 --- a/ext/standard/filestat.c +++ b/ext/standard/filestat.c @@ -618,6 +618,30 @@ static void php_stat(const char *filename, php_stat_len filename_length, int typ #else add_next_index_long(return_value, -1); #endif + /* Support string references as well as numerical*/ + add_assoc_long ( return_value , "dev" , stat_sb->st_dev ); + add_assoc_long ( return_value , "ino" , stat_sb->st_ino ); + add_assoc_long ( return_value , "mode" , stat_sb->st_mode ); + add_assoc_long ( return_value , "nlink" , stat_sb->st_nlink ); + add_assoc_long ( return_value , "uid" , stat_sb->st_uid ); + add_assoc_long ( return_value , "gid" , stat_sb->st_gid ); + +#ifdef HAVE_ST_RDEV + add_assoc_long ( return_value, "rdev" , stat_sb->st_rdev ); +#endif +#ifdef HAVE_ST_BLKSIZE + add_assoc_long ( return_value , "blksize" , stat_sb->st_blksize ); +#endif + + add_assoc_long ( return_value , "size" , stat_sb->st_size ); + add_assoc_long ( return_value , "atime" , stat_sb->st_atime ); + add_assoc_long ( return_value , "mtime" , stat_sb->st_mtime ); + add_assoc_long ( return_value , "ctime" , stat_sb->st_ctime ); + +#ifdef HAVE_ST_BLOCKS + add_assoc_long ( return_value , "blocks" , stat_sb->st_blocks ); +#endif + return; } php_error(E_WARNING, "didn't understand stat call"); -- 2.50.1