Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1008)

Unified Diff: native_client_sdk/src/libraries/nacl_io/html5fs/html5_fs_node.cc

Issue 1293543006: Make the default directory size returned by stat to be 4096 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | native_client_sdk/src/tests/nacl_io_test/html5_fs_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: native_client_sdk/src/libraries/nacl_io/html5fs/html5_fs_node.cc
diff --git a/native_client_sdk/src/libraries/nacl_io/html5fs/html5_fs_node.cc b/native_client_sdk/src/libraries/nacl_io/html5fs/html5_fs_node.cc
index bb3a8f5ac3524d3370ddc2f6f73b2b4aff2b9f08..76eff01b6ee33e2da58e90da15f19b89625d935c 100644
--- a/native_client_sdk/src/libraries/nacl_io/html5fs/html5_fs_node.cc
+++ b/native_client_sdk/src/libraries/nacl_io/html5fs/html5_fs_node.cc
@@ -26,6 +26,8 @@ namespace nacl_io {
namespace {
+const int kEmptyDirSize = 4096;
+
struct OutputBuffer {
void* data;
int element_count;
@@ -156,6 +158,8 @@ Error Html5FsNode::GetStat(struct stat* stat) {
// Fill in known info here.
memcpy(stat, &stat_, sizeof(stat_));
+ stat->st_size = static_cast<off_t>(info.size);
+
// Fill in the additional info from ppapi.
switch (info.type) {
case PP_FILETYPE_REGULAR:
@@ -163,12 +167,15 @@ Error Html5FsNode::GetStat(struct stat* stat) {
break;
case PP_FILETYPE_DIRECTORY:
stat->st_mode |= S_IFDIR;
+ // Hack the directory size
+ // In Linux, even a empty directory has size 4096
+ // info.size is always zero for directories
+ stat->st_size = kEmptyDirSize;
break;
case PP_FILETYPE_OTHER:
default:
break;
}
- stat->st_size = static_cast<off_t>(info.size);
stat->st_atime = info.last_access_time;
stat->st_mtime = info.last_modified_time;
stat->st_ctime = info.creation_time;
« no previous file with comments | « no previous file | native_client_sdk/src/tests/nacl_io_test/html5_fs_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698