Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Member Functions | List of all members
net_instaweb::StdioFileSystem Class Reference
Inheritance diagram for net_instaweb::StdioFileSystem:
net_instaweb::FileSystem

Public Member Functions

virtual int MaxPathLength (const StringPiece &base) const
 
virtual InputFileOpenInputFile (const char *filename, MessageHandler *message_handler)
 
virtual OutputFileOpenOutputFileHelper (const char *filename, bool append, MessageHandler *message_handler)
 
virtual OutputFileOpenTempFileHelper (const StringPiece &prefix_name, MessageHandler *message_handle)
 
virtual bool ListContents (const StringPiece &dir, StringVector *files, MessageHandler *handler)
 
virtual bool MakeDir (const char *directory_path, MessageHandler *handler)
 
virtual bool RemoveDir (const char *directory_path, MessageHandler *handler)
 Like POSIX 'rmdir', remove a directory only if it is empty.
 
virtual bool RemoveFile (const char *filename, MessageHandler *handler)
 Like POSIX 'rm'.
 
virtual bool RenameFileHelper (const char *old_file, const char *new_file, MessageHandler *handler)
 
virtual bool Atime (const StringPiece &path, int64 *timestamp_sec, MessageHandler *handler)
 
virtual bool Mtime (const StringPiece &path, int64 *timestamp_sec, MessageHandler *handler)
 Modified time. Time the file contents were modified.
 
virtual bool Size (const StringPiece &path, int64 *size, MessageHandler *handler) const
 
virtual BoolOrError Exists (const char *path, MessageHandler *handler)
 Like POSIX 'test -e', checks if path exists (is a file, directory, etc.).
 
virtual BoolOrError IsDir (const char *path, MessageHandler *handler)
 Like POSIX 'test -d', checks if path exists and refers to a directory.
 
virtual BoolOrError TryLock (const StringPiece &lock_name, MessageHandler *handler)
 
virtual BoolOrError TryLockWithTimeout (const StringPiece &lock_name, int64 timeout_ms, const Timer *timer, MessageHandler *handler)
 
virtual bool BumpLockTimeout (const StringPiece &lock_name, MessageHandler *handler)
 
virtual bool Unlock (const StringPiece &lock_name, MessageHandler *handler)
 
InputFileStdin ()
 
OutputFileStdout ()
 
OutputFileStderr ()
 
void TrackTiming (int64 slow_file_latency_threshold_us, Timer *timer, Statistics *stats, MessageHandler *handler)
 
int64 StartTimer ()
 
void EndTimer (const char *filename, const char *operation, int64 start_us)
 
- Public Member Functions inherited from net_instaweb::FileSystem
virtual bool ReadFile (const char *filename, int64 max_file_size, Writer *writer, MessageHandler *handler)
 
virtual bool ReadFile (InputFile *input_file, int64 max_file_size, Writer *writer, MessageHandler *handler)
 
virtual bool ReadFile (const char *filename, int64 max_file_size, GoogleString *buffer, MessageHandler *handler)
 
virtual bool ReadFile (InputFile *input_file, int64 max_file_size, GoogleString *buffer, MessageHandler *handler)
 
virtual bool ReadFile (const char *filename, GoogleString *buffer, MessageHandler *handler)
 
virtual bool ReadFile (InputFile *input_file, GoogleString *buffer, MessageHandler *handler)
 
virtual bool ReadFile (const char *filename, Writer *writer, MessageHandler *handler)
 
virtual bool ReadFile (InputFile *input_file, Writer *writer, MessageHandler *handler)
 
virtual bool WriteFile (const char *filename, const StringPiece &buffer, MessageHandler *handler)
 Non-atomic. Use WriteFileAtomic() for atomic version.
 
virtual bool WriteTempFile (const StringPiece &prefix_name, const StringPiece &buffer, GoogleString *filename, MessageHandler *handler)
 
bool WriteFileAtomic (const StringPiece &filename, const StringPiece &buffer, MessageHandler *handler)
 
OutputFileOpenOutputFile (const char *filename, MessageHandler *handler)
 Automatically creates sub-directories to filename.
 
OutputFileOpenOutputFileForAppend (const char *filename, MessageHandler *handler)
 
OutputFileOpenTempFile (const StringPiece &prefix_name, MessageHandler *handler)
 
virtual bool Close (File *file, MessageHandler *handler)
 Closes the File and cleans up memory.
 
bool RenameFile (const char *old_filename, const char *new_filename, MessageHandler *handler)
 
virtual bool RecursivelyMakeDir (const StringPiece &directory_path, MessageHandler *handler)
 
void GetDirInfo (const StringPiece &path, DirInfo *dirinfo, MessageHandler *handler)
 
virtual void GetDirInfoWithProgress (const StringPiece &path, DirInfo *dirinfo, ProgressNotifier *notifier, MessageHandler *handler)
 

Static Public Member Functions

static void InitStats (Statistics *stats)
 

Additional Inherited Members

- Static Public Attributes inherited from net_instaweb::FileSystem
static const int64 kUnlimitedSize = -1
 This is documented as -1 in user-facing documentation, so don't change it.
 

Member Function Documentation

virtual bool net_instaweb::StdioFileSystem::Atime ( const StringPiece &  path,
int64 *  timestamp_sec,
MessageHandler handler 
)
virtual

Stores in *timestamp_sec the timestamp (in seconds since the epoch) of the last time the file was accessed (through one of our Read methods, or by someone else accessing the filesystem directly). Returns true on success, false on failure.

Todo:
TODO(abliss): replace this with a single Stat() function.

Implements net_instaweb::FileSystem.

virtual bool net_instaweb::StdioFileSystem::BumpLockTimeout ( const StringPiece &  lock_name,
MessageHandler handler 
)
virtual

If you're holding a lock for a long running task you want to avoid someone else receiving the lock if they request it with TryLockWithTimeout because you've been working for longer than the timeout, you should bump it often enough that it doesn't expire.

Default implementation does nothing, since the default implementation of TryLockWithTimeout doesn't do anything either.

Reimplemented from net_instaweb::FileSystem.

virtual bool net_instaweb::StdioFileSystem::ListContents ( const StringPiece &  dir,
StringVector *  files,
MessageHandler handler 
)
virtual

Like POSIX 'ls -a', lists all files and directories under the given directory (but omits "." and ".."). Full paths (not just filenames) will be pushed onto the back of the supplied vector (without clearing it). Returns true on success (even if the dir was empty), false on error (even if some files were pushed onto the vector). This is generally not threadsafe! Use a mutex.

Implements net_instaweb::FileSystem.

virtual bool net_instaweb::StdioFileSystem::MakeDir ( const char *  directory_path,
MessageHandler handler 
)
virtual

Like POSIX 'mkdir', makes a directory only if parent directory exists. Fails if directory_name already exists or parent directory doesn't exist.

Implements net_instaweb::FileSystem.

virtual int net_instaweb::StdioFileSystem::MaxPathLength ( const StringPiece &  base) const
virtual

Returns the maximum possible length of a path in a given directory. Note that this is the total, and there may be further constraints on each level. It also depends on the base path.

Default implementation defensively returns 8192.

Reimplemented from net_instaweb::FileSystem.

virtual OutputFile* net_instaweb::StdioFileSystem::OpenOutputFileHelper ( const char *  filename,
bool  append,
MessageHandler handler 
)
virtual

These interfaces must be defined by implementers of FileSystem. They may assume the directory already exists.

Implements net_instaweb::FileSystem.

virtual bool net_instaweb::StdioFileSystem::Size ( const StringPiece &  path,
int64 *  size,
MessageHandler handler 
) const
virtual

Report the disk utilization of the file specified by path. Note that disk utilization could differ from the apparent size of the file as it depends on the underlying file system and default block size.

Implements net_instaweb::FileSystem.

virtual BoolOrError net_instaweb::StdioFileSystem::TryLock ( const StringPiece &  lock_name,
MessageHandler handler 
)
virtual

Attempts to obtain a global (cross-process, cross-thread) lock of the given name (which should be a valid filename, not otherwise used, in an extant directory). If someone else has this lock, returns False immediately. If anything goes wrong, returns Error. On success, returns True: then you must call Unlock when you are done.

Implements net_instaweb::FileSystem.

virtual BoolOrError net_instaweb::StdioFileSystem::TryLockWithTimeout ( const StringPiece &  lock_name,
int64  timeout_millis,
const Timer timer,
MessageHandler handler 
)
virtual

Like TryLock, but may attempt to break stale locks, though the default implementation never actually breaks any. A lock is stale if it was taken (or last bumped) more than timeout_millis ms ago.

If you obtain a lock through this method, there are no hard guarantees that nobody else has it too. <blink> If you use this function, your lock becomes "best-effort". </blink>

If you override this function, you need to override BumpLockTimeout as well.

Reimplemented from net_instaweb::FileSystem.

virtual bool net_instaweb::StdioFileSystem::Unlock ( const StringPiece &  lock_name,
MessageHandler handler 
)
virtual

Attempts to release a lock previously obtained through TryLock. If your thread did not previously obtain the lock, the behavior is undefined. Returns true if we successfully release the lock. Returns false if we were unable to release the lock (e.g. somebody came along and write-protected the lockfile). You might try again, or start using a different lock name.

Implements net_instaweb::FileSystem.


The documentation for this class was generated from the following file: