Skip to content

Commit

Permalink
Style cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
colincornaby committed Jul 9, 2024
1 parent f82cf31 commit e8af3a3
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 36 deletions.
31 changes: 19 additions & 12 deletions Sources/Plasma/Apps/plClient/Mac-Cocoa/PLSPatcher.mm
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,7 @@ - (NSURL *)completeSelfPatch:(NSError **)error;

if (!self.updatedClientURL) {
// uh oh - this implies we weren't able to decompress the client
if (error)
{
if (error) {
// Handle as a generic could not read file error.
// Bad compression on the server will require correction on the server end.
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadNoSuchFileError userInfo:nil];
Expand Down Expand Up @@ -197,11 +196,11 @@ bool IApproveDownload(const plFileName& file)
return extExcludeList.find(file.GetFileExt()) == extExcludeList.end();
}

static la_ssize_t copy_data(struct archive *ar, struct archive *aw)
static la_ssize_t copy_data(struct archive* ar, struct archive* aw)
{
while (true) {
la_ssize_t r;
const void *buff;
const void* buff;
size_t size;
la_int64_t offset;

Expand All @@ -212,7 +211,7 @@ static la_ssize_t copy_data(struct archive *ar, struct archive *aw)
return (r);
r = archive_write_data_block(aw, buff, size, offset);
if (r < ARCHIVE_OK) {
fprintf(stderr, "%s\n", archive_error_string(aw));
plStatusLog::AddLineSF("%s\n", archive_error_string(aw));
return (r);
}
}
Expand All @@ -236,8 +235,8 @@ static la_ssize_t copy_data(struct archive *ar, struct archive *aw)
/* Select which attributes we want to restore. */
flags = ARCHIVE_EXTRACT_TIME | ARCHIVE_EXTRACT_PERM;

struct archive *a = archive_read_new();
struct archive *ext = archive_write_disk_new();
struct archive* a = archive_read_new();
struct archive* ext = archive_write_disk_new();

{
int error;
Expand All @@ -260,8 +259,13 @@ static la_ssize_t copy_data(struct archive *ar, struct archive *aw)
}

NSError *error;
patcher.temporaryDirectory = [NSFileManager.defaultManager URLForDirectory:NSItemReplacementDirectory inDomain:NSUserDomainMask appropriateForURL:[NSURL fileURLWithPath:NSFileManager.defaultManager.currentDirectoryPath] create:YES error:&error];
NSURL *outputURL;
NSURL* currentDirectory = [NSURL fileURLWithPath:NSFileManager.defaultManager.currentDirectoryPath];
patcher.temporaryDirectory = [NSFileManager.defaultManager
URLForDirectory:NSItemReplacementDirectory
inDomain:NSUserDomainMask
appropriateForURL:currentDirectory
create:YES error:&error];
NSURL* outputURL;
if (patcher.temporaryDirectory) {
outputURL = [patcher.temporaryDirectory URLByAppendingPathComponent:[NSString stringWithSTString:plManifest::PatcherExecutable().GetFileName()]];
[NSFileManager.defaultManager createDirectoryAtURL:outputURL withIntermediateDirectories:false attributes:nil error:&error];
Expand All @@ -272,14 +276,18 @@ static la_ssize_t copy_data(struct archive *ar, struct archive *aw)
// get a writable temp directory. But if we could not, bail.
// Not populating the patched client path will be caught
// later.
archive_read_close(a);
archive_read_free(a);
archive_write_close(ext);
archive_write_free(ext);
return;
}

ST::string outputPath = [outputURL.path STString];

bool succeeded = true;

struct archive_entry *entry;
struct archive_entry* entry;
while (true) {
r = archive_read_next_header(a, &entry);
if (r == ARCHIVE_EOF)
Expand Down Expand Up @@ -320,8 +328,7 @@ static la_ssize_t copy_data(struct archive *ar, struct archive *aw)

plFileSystem::Unlink(file);

if (succeeded)
{
if (succeeded) {
parent.updatedClientURL = outputURL;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ - (void)patcherCompleted:(nonnull PLSPatcher *)patcher didSelfPatch:(BOOL)selfPa
// intercepted by the application
}


- (void)observeValueForKeyPath:(NSString*)keyPath
ofObject:(id)object
change:(NSDictionary*)change
Expand Down
17 changes: 2 additions & 15 deletions Sources/Plasma/CoreLib/plFileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,23 +84,10 @@ You can contact Cyan Worlds, Inc. by email [email protected]

ST::string plFileName::GetFileName() const
{
if(fName.ends_with("/"))
{
if (fName.ends_with("/"))
return plFileName(fName.before_last('/')).GetFileName();
}
ST_ssize_t end = fName.find_last('/');
if (end < 0)
end = fName.find_last('\\');
if (end < 0)
return fName;

return fName.substr(end + 1);
}

ST::string plFileName::GetFileExt() const
{

ST_ssize_t dot = fName.find_last('.');

// Be sure not to get a dot in the directory!
ST_ssize_t end = fName.find_last('/');
if (end < 0)
Expand Down
16 changes: 8 additions & 8 deletions Sources/Plasma/FeatureLib/pfPatcher/plManifests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,25 +52,25 @@ Mead, WA 99021
# define MANIFEST(in, ex) in
#endif // PLASMA_EXTERNAL_RELEASE

#if HS_BUILD_FOR_APPLE
# define PL_EXECUTABLE_SUFFIX ".app"
#elif HS_BUILD_FOR_WIN32
# define PL_EXECUTABLE_SUFFIX ".exe"
#if defined(HS_BUILD_FOR_APPLE)
# define EXECUTABLE_SUFFIX ".app"
#elif defined(HS_BUILD_FOR_WIN32)
# define EXECUTABLE_SUFFIX ".exe"
#else
# define PL_EXECUTABLE_SUFFIX ""
# define EXECUTABLE_SUFFIX ""
#endif

plFileName plManifest::ClientExecutable()
{
return MANIFEST("plClient" PL_EXECUTABLE_SUFFIX, "UruExplorer" PL_EXECUTABLE_SUFFIX);
return MANIFEST("plClient" EXECUTABLE_SUFFIX, "UruExplorer" EXECUTABLE_SUFFIX);
}

plFileName plManifest::PatcherExecutable()
{
#ifdef HS_BUILD_FOR_MACOS
return MANIFEST("plClient" PL_EXECUTABLE_SUFFIX, "UruExplorer" PL_EXECUTABLE_SUFFIX);
return MANIFEST("plClient" EXECUTABLE_SUFFIX, "UruExplorer" EXECUTABLE_SUFFIX);
#else
return MANIFEST("plUruLauncher" PL_EXECUTABLE_SUFFIX, "UruLauncher" PL_EXECUTABLE_SUFFIX);
return MANIFEST("plUruLauncher" EXECUTABLE_SUFFIX, "UruLauncher" EXECUTABLE_SUFFIX);
#endif
}

Expand Down

0 comments on commit e8af3a3

Please sign in to comment.