Loading...
Searching...
No Matches
filesystemAsset.h
Go to the documentation of this file.
1//
2// Copyright 2021 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6#ifndef PXR_USD_AR_FILESYSTEM_ASSET_H
7#define PXR_USD_AR_FILESYSTEM_ASSET_H
8
10
11#include "pxr/pxr.h"
12#include "pxr/usd/ar/api.h"
13#include "pxr/usd/ar/asset.h"
15
16#include <cstdio>
17#include <memory>
18#include <utility>
19
20PXR_NAMESPACE_OPEN_SCOPE
21
22class ArResolvedPath;
23
28 : public ArAsset
29{
30public:
33 AR_API
34 static std::shared_ptr<ArFilesystemAsset> Open(
35 const ArResolvedPath& resolvedPath);
36
39 AR_API
41 const ArResolvedPath& resolvedPath);
42
46 AR_API
47 explicit ArFilesystemAsset(FILE* file);
48
50 AR_API
52
54 AR_API
55 virtual size_t GetSize() const override;
56
59 AR_API
60 virtual std::shared_ptr<const char> GetBuffer() const override;
61
64 AR_API
65 virtual size_t Read(
66 void* buffer, size_t count, size_t offset) const override;
67
71 AR_API
72 virtual std::pair<FILE*, size_t> GetFileUnsafe() const override;
73
74private:
75 FILE* _file;
76};
77
78PXR_NAMESPACE_CLOSE_SCOPE
79
80#endif // PXR_USD_AR_FILESYSTEM_ASSET_H
Interface for accessing the contents of an asset.
Definition: asset.h:27
ArAsset implementation for asset represented by a file on a filesystem.
AR_API ~ArFilesystemAsset()
Closes the file owned by this object.
virtual AR_API size_t GetSize() const override
Returns the size of the file held by this object.
virtual AR_API std::pair< FILE *, size_t > GetFileUnsafe() const override
Returns the FILE* handle this object was created with and an offset of 0, since the asset's contents ...
static AR_API std::shared_ptr< ArFilesystemAsset > Open(const ArResolvedPath &resolvedPath)
Constructs a new ArFilesystemAsset for the file at resolvedPath.
AR_API ArFilesystemAsset(FILE *file)
Constructs an ArFilesystemAsset for the given file.
virtual AR_API size_t Read(void *buffer, size_t count, size_t offset) const override
Reads count bytes from the file held by this object at the given offset into buffer.
static AR_API ArTimestamp GetModificationTimestamp(const ArResolvedPath &resolvedPath)
Returns an ArTimestamp holding the mtime of the file at resolvedPath.
virtual AR_API std::shared_ptr< const char > GetBuffer() const override
Creates a read-only memory map for the file held by this object and returns a pointer to the start of...
Represents a resolved asset path.
Definition: resolvedPath.h:23
Represents a timestamp for an asset.
Definition: timestamp.h:26