summaryrefslogtreecommitdiff
path: root/src/stable
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2014-07-22 16:39:01 +0000
committerMike Buland <eichlan@xagasoft.com>2014-07-22 16:39:01 +0000
commit21a4337dc2f969dc3ec81e6ba3170119bcb67016 (patch)
treeaf8077ea0e89ec29b499e46583f3de35d1b3103c /src/stable
parent6482ec1f7550f0fca153bd8f556327902c7afec8 (diff)
downloadlibbu++-21a4337dc2f969dc3ec81e6ba3170119bcb67016.tar.gz
libbu++-21a4337dc2f969dc3ec81e6ba3170119bcb67016.tar.bz2
libbu++-21a4337dc2f969dc3ec81e6ba3170119bcb67016.tar.xz
libbu++-21a4337dc2f969dc3ec81e6ba3170119bcb67016.zip
Deferred erase now works on cache entries. You can erase a cache entry while
it still has active references, and it will be safely cleaned up when the last reference is released.
Diffstat (limited to 'src/stable')
-rw-r--r--src/stable/array.h24
-rw-r--r--src/stable/file.cpp9
-rw-r--r--src/stable/file.h4
3 files changed, 35 insertions, 2 deletions
diff --git a/src/stable/array.h b/src/stable/array.h
index a598865..a662705 100644
--- a/src/stable/array.h
+++ b/src/stable/array.h
@@ -297,6 +297,30 @@ namespace Bu
297 return core->iSize; 297 return core->iSize;
298 } 298 }
299 299
300 void setSize( long iNewLen, const value &initTo=value() )
301 {
302 if( core->iSize == iNewLen )
303 return;
304
305 _hardCopy();
306 if( iNewLen > core->iCapacity )
307 {
308 core->setCapacity( iNewLen );
309 for( int j = core->iSize; j < iNewLen; j++ )
310 {
311 core->va.construct(
312 &core->pData[j],
313 initTo
314 );
315 }
316 core->iSize = iNewLen;
317 }
318 else
319 {
320 core->iSize = iNewLen;
321 }
322 }
323
300 /** 324 /**
301 * Get the capacity of the array. This number will grow as data is 325 * Get the capacity of the array. This number will grow as data is
302 * added, and is mainly for the curious, it doesn't really determine 326 * added, and is mainly for the curious, it doesn't really determine
diff --git a/src/stable/file.cpp b/src/stable/file.cpp
index b551d24..35933f1 100644
--- a/src/stable/file.cpp
+++ b/src/stable/file.cpp
@@ -240,7 +240,7 @@ void Bu::File::setSize( Bu::size iSize )
240 240
241Bu::size Bu::File::getSize() const 241Bu::size Bu::File::getSize() const
242{ 242{
243 struct stat st; 243 struct ::stat st;
244 fstat( fd, &st ); 244 fstat( fd, &st );
245 return st.st_size; 245 return st.st_size;
246} 246}
@@ -250,7 +250,7 @@ Bu::size Bu::File::getBlockSize() const
250#ifdef WIN32 250#ifdef WIN32
251 return 4096; 251 return 4096;
252#else 252#else
253 struct stat st; 253 struct ::stat st;
254 fstat( fd, &st ); 254 fstat( fd, &st );
255 return st.st_blksize; 255 return st.st_blksize;
256#endif 256#endif
@@ -261,6 +261,11 @@ Bu::String Bu::File::getLocation() const
261 return "to be implemented"; 261 return "to be implemented";
262} 262}
263 263
264void Bu::File::stat( struct ::stat *pStat )
265{
266 fstat( fd, pStat );
267}
268
264#ifndef WIN32 269#ifndef WIN32
265void Bu::File::chmod( mode_t t ) 270void Bu::File::chmod( mode_t t )
266{ 271{
diff --git a/src/stable/file.h b/src/stable/file.h
index ad60e80..e3497d3 100644
--- a/src/stable/file.h
+++ b/src/stable/file.h
@@ -15,6 +15,8 @@
15#include "bu/string.h" 15#include "bu/string.h"
16#include "bu/exceptionbase.h" 16#include "bu/exceptionbase.h"
17 17
18struct stat;
19
18namespace Bu 20namespace Bu
19{ 21{
20 subExceptionDecl( FileException ); 22 subExceptionDecl( FileException );
@@ -76,6 +78,8 @@ namespace Bu
76 virtual size getBlockSize() const; 78 virtual size getBlockSize() const;
77 virtual Bu::String getLocation() const; 79 virtual Bu::String getLocation() const;
78 80
81 void stat( struct ::stat *pStat );
82
79 /** 83 /**
80 * Create a temp file and return its handle. The file is opened 84 * Create a temp file and return its handle. The file is opened
81 * Read/Write. 85 * Read/Write.