2.4.3 (latest) 2.4.2 2.3.1 2.2.2 Reference documentation and code samples for the Google Cloud Platform environment queries class Google::Cloud::Env::FileSystem.

Access to file system contents.


This is a simple class that reads the contents of objects in the file
system, caching data so that subsequent accesses do not need to reread
the file system.

You can also "mock" the file system by providing a hash of overrides.
If overrides are present, actual file system access is disabled; that
is, overrides are "all or nothing".

<br />

This class does not provide any controls for data size. If you read a
large file, its contents will stay in memory for the lifetime of the
Ruby process.

## Inherits

- Object

## Methods

### #initialize

```ruby
def initialize() -> FileSystem
```
Create a file system access object with no overrides.
**Returns**

- ([FileSystem](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-env/latest/Google-Cloud-Env-FileSystem.md.txt)) --- a new instance of FileSystem

### #overrides

```ruby
def overrides() -> Hash{String => String}, nil
```
The overrides hash, or nil if overrides are not present.
The hash maps paths to contents of the file at that path.
**Returns**

- (Hash{String =\> String}, nil)

### #overrides=

```ruby
def overrides=(new_overrides)
```
Set the overrides hash. You can either provide a hash of file paths
to content, or nil to disable overrides. If overrides are present,
actual filesystem access is disabled; overrides are "all or nothing".

### #read

```ruby
def read(path, binary: false) -> String, nil
```
Read the given file from the file system and return its contents.
**Parameters**

- **path** (String) --- The path to the file.
- **binary** (boolean) *(defaults to: false)* --- Whether to read in binary mode. Defaults to false. This must be consistent across multiple requests for the same path; if it is not, an error will be raised.
**Returns**

- (String) --- if the file exists.
- (nil) --- if the file does not exist.

### #with_overrides

```ruby
def with_overrides(temp_overrides)
```
Run the given block with the overrides replaced with the given hash
(or nil to disable overrides in the block). The original overrides
setting is restored at the end of the block. This is used for
debugging/testing/mocking.
**Parameter**

- **temp_overrides** (nil, Hash{String =\> String})