summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-repro.cpp
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2021-10-04 14:15:51 -0400
committerGitHub <noreply@github.com>2021-10-04 14:15:51 -0400
commit97bb82ebcdf8f1391b9d93b5a8d7b1dfc4e88e52 (patch)
treef120ba282cbea96d23ed179737984a4610d3b520 /source/slang/slang-repro.cpp
parentb3dfe383c6d31ff3dbd76dcfb32de8d536382f3e (diff)
Removing exceptions from core/compiler-core (#1953)
* #include an absolute path didn't work - because paths were taken to always be relative. * Refactor Stream. Working on all tests. * Split out CharEncode. * Make method names lower camel. m_prefix in Writer/Reader * Tidy up around CharEncode interface. * Small improvements around encode/decode. * Better use of types. * Remove readLine from TextReader. * Remove exceptions from Stream/Text handling. * Fix some typos. * Fix tabbing. * Fix missing override. * Remove remaining exception throw/catch via using signal mechanism. * Remove exceptions that are not used anymore. * Document the Stream interface. * Remove index for decoding 'get byte' function. * Fix CharReader -> ByteReader.
Diffstat (limited to 'source/slang/slang-repro.cpp')
-rw-r--r--source/slang/slang-repro.cpp26
1 files changed, 9 insertions, 17 deletions
diff --git a/source/slang/slang-repro.cpp b/source/slang/slang-repro.cpp
index 4b3148278..67feebe43 100644
--- a/source/slang/slang-repro.cpp
+++ b/source/slang/slang-repro.cpp
@@ -1082,22 +1082,15 @@ struct LoadContext
/* static */SlangResult ReproUtil::saveState(EndToEndCompileRequest* request, const String& filename)
{
- RefPtr<Stream> stream(new FileStream(filename, FileMode::Create, FileAccess::Write, FileShare::ReadWrite));
+ RefPtr<FileStream> stream(new FileStream);
+ SLANG_RETURN_ON_FAIL(stream->init(filename, FileMode::Create, FileAccess::Write, FileShare::ReadWrite));
return saveState(request, stream);
}
/* static */ SlangResult ReproUtil::loadState(const String& filename, List<uint8_t>& outBuffer)
{
- RefPtr<Stream> stream;
- try
- {
- stream = new FileStream(filename, FileMode::Open, FileAccess::Read, FileShare::ReadWrite);
- }
- catch (const IOException&)
- {
- return SLANG_FAIL;
- }
-
+ RefPtr<FileStream> stream = new FileStream;
+ SLANG_RETURN_ON_FAIL(stream->init(filename, FileMode::Open, FileAccess::Read, FileShare::ReadWrite));
return loadState(stream, outBuffer);
}
@@ -1564,6 +1557,8 @@ static SlangResult _findFirstSourcePath(EndToEndCompileRequest* request, String&
String sourceFileName = Path::getFileName(sourcePath);
String sourceBaseName = Path::getFileNameWithoutExt(sourceFileName);
+ RefPtr<FileStream> stream = new FileStream;
+
// Okay we need a unique number to make sure the name is unique
const int maxTries = 100;
for (int triesCount = 0; triesCount < maxTries; ++triesCount)
@@ -1578,15 +1573,12 @@ static SlangResult _findFirstSourcePath(EndToEndCompileRequest* request, String&
outFileName = builder;
// We could have clashes, as we use ticks, we should get to a point where the clashes stop
- try
+ if (SLANG_SUCCEEDED(stream->init(builder, FileMode::CreateNew, FileAccess::Write, FileShare::WriteOnly)))
{
- outStream = new FileStream(builder, FileMode::CreateNew, FileAccess::Write, FileShare::WriteOnly);
+ outStream = stream;
return SLANG_OK;
}
- catch (const IOException&)
- {
- }
-
+
// TODO(JS):
// Might make sense to sleep here - but don't seem to have cross platform func for that yet.
}