Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
mikee47 committed Jul 3, 2024
2 parents c564d2c + 4437e76 commit a377908
Show file tree
Hide file tree
Showing 46 changed files with 520 additions and 239 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/ci-dispatch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: CI Dispatch

on:
workflow_dispatch:
inputs:
sming_repo:
description: 'Full URL for Sming repository'
default: 'https://github.com/SmingHub/Sming'
type: string
sming_branch:
description: 'Sming branch to run against'
default: 'develop'
type: string

jobs:
build:
uses: SmingHub/Sming/.github/workflows/library.yml@develop
with:
sming_repo: ${{ inputs.sming_repo }}
sming_branch: ${{ inputs.sming_branch }}
7 changes: 7 additions & 0 deletions .github/workflows/ci-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: CI Push

on: [push, pull_request]

jobs:
build:
uses: SmingHub/Sming/.github/workflows/library.yml@develop
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,8 @@ Such a system would require almost no static RAM allocation and code size would


However, the :library:`LittleFS` has excellent metadata support and is ideal for storing configuration information.
This can be done using :IFS::FileSystem::`setUserAttribute` and read using :IFS::FileSystem::`getUserAttribute`
or :IFS::FileSystem::`enumAttributes`.
This can be done using :cpp:func:`IFS::FileSystem::setUserAttribute` and read using :cpp:func:`IFS::FileSystem::getUserAttribute`
or :cpp:func:`IFS::FileSystem::enumAttributes`.


.. note::
Expand Down
39 changes: 31 additions & 8 deletions src/Arch/Host/FileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
*
****/

#define _POSIX_C_SOURCE 200112L

#include <IFS/Host/FileSystem.h>
#include <IFS/Host/Util.h>
#include <IFS/Util.h>
Expand Down Expand Up @@ -65,6 +63,9 @@ namespace Host
#ifdef __WIN32
struct os_stat_t : public ::_stati64 {
};
#elif defined(__APPLE__)
struct os_stat_t : public ::stat {
};
#else
struct os_stat_t : public ::stat64 {
};
Expand All @@ -88,7 +89,7 @@ const char* extendedAttributePrefix{"user.ifs."};

int setXAttr(FileHandle file, const char* name, const void* value, size_t size)
{
#if defined(__MACOS)
#if defined(__APPLE__)
int res = ::fsetxattr(file, name, value, size, 0, 0);
#else
int res = ::fsetxattr(file, name, value, size, 0);
Expand All @@ -98,7 +99,7 @@ int setXAttr(FileHandle file, const char* name, const void* value, size_t size)

int getXAttr(FileHandle file, const char* name, void* value, size_t size)
{
#if defined(__MACOS)
#if defined(__APPLE__)
auto len = ::fgetxattr(file, name, value, size, 0, 0);
#else
auto len = ::fgetxattr(file, name, value, size);
Expand All @@ -108,7 +109,7 @@ int getXAttr(FileHandle file, const char* name, void* value, size_t size)

int listXAttr(FileHandle file, char* namebuf, size_t size)
{
#if defined(__MACOS)
#if defined(__APPLE__)
auto len = ::flistxattr(file, namebuf, size, 0);
#else
auto len = ::flistxattr(file, namebuf, size);
Expand Down Expand Up @@ -191,8 +192,10 @@ int settime(const char* path, TimeStamp mtime)
_utimbuf times{mtime, mtime};
int res = _utime(path, &times);
#else
struct utimbuf times[]{mtime, mtime};
int res = ::utime(path, times);
struct utimbuf times {
mtime, mtime
};
int res = ::utime(path, &times);
#endif
return (res >= 0) ? res : syserr();
}
Expand All @@ -216,7 +219,7 @@ int FileSystem::mount()
int res = ::stat(rootpath.c_str(), &s);
if(res < 0) {
res = syserr();
debug_e("[FS] Mount '%s' failed, %s", rootpath.c_str(), getErrorString(res));
debug_e("[FS] Mount '%s' failed, %s", rootpath.c_str(), getErrorString(res).c_str());
return res;
}
if(!S_ISDIR(s.st_mode)) {
Expand Down Expand Up @@ -360,7 +363,11 @@ int FileSystem::stat(const char* path, Stat* stat)
String fullpath = resolvePath(path);

os_stat_t s;
#ifdef __APPLE__
int res = ::stat(fullpath.c_str(), &s);
#else
int res = ::stat64(fullpath.c_str(), &s);
#endif
if(res < 0) {
return syserr();
}
Expand All @@ -384,7 +391,11 @@ int FileSystem::fstat(FileHandle file, Stat* stat)
CHECK_MOUNTED()

os_stat_t s;
#ifdef __APPLE__
int res = ::fstat(file, &s);
#else
int res = ::fstat64(file, &s);
#endif
if(res < 0) {
return syserr();
}
Expand Down Expand Up @@ -608,7 +619,11 @@ file_offset_t FileSystem::lseek(FileHandle file, file_offset_t offset, SeekOrigi
{
CHECK_MOUNTED()

#ifdef __APPLE__
auto res = ::lseek(file, offset, uint8_t(origin));
#else
auto res = ::lseek64(file, offset, uint8_t(origin));
#endif
if(res < 0) {
return syserr();
}
Expand All @@ -632,7 +647,11 @@ int FileSystem::eof(FileHandle file)
}

os_stat_t stat;
#ifdef __APPLE__
int err = ::fstat(file, &stat);
#else
int err = ::fstat64(file, &stat);
#endif
if(err < 0) {
return syserr();
}
Expand All @@ -649,7 +668,11 @@ int FileSystem::ftruncate(FileHandle file, file_size_t new_size)
{
CHECK_MOUNTED()

#ifdef __APPLE__
int res = ::ftruncate(file, new_size);
#else
int res = ::ftruncate64(file, new_size);
#endif
return (res >= 0) ? res : syserr();
}

Expand Down
4 changes: 2 additions & 2 deletions src/Arch/Host/Windows/xattr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace
constexpr size_t nameSize{32};
constexpr size_t contentSize{1024};

NTSTATUS getExtendedAttribute(HANDLE hFile, const char* name, void* buffer, size_t bufSize, size_t& length)
NTSTATUS getExtendedAttribute(HANDLE hFile, const char* name, void* buffer, size_t& length)
{
char buf[sizeof(FILE_FULL_EA_INFORMATION) + nameSize + contentSize];
auto get = reinterpret_cast<FILE_GET_EA_INFORMATION*>(buf);
Expand Down Expand Up @@ -147,7 +147,7 @@ int fgetxattr(int file, const char* name, void* value, size_t size)
{
EaBuffer buffer(name);
size_t length;
auto status = getExtendedAttribute(getHandle(file), buffer.name, buffer.content, contentSize, length);
auto status = getExtendedAttribute(getHandle(file), buffer.name, buffer.content, length);
errno = getErrno(status);
if(status != STATUS_SUCCESS) {
return -1;
Expand Down
13 changes: 4 additions & 9 deletions src/Arch/Host/include/IFS/Host/FileSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@

#include <IFS/IFileSystem.h>

namespace IFS
{
namespace Host
namespace IFS::Host
{
struct os_stat_t;

Expand All @@ -40,9 +38,7 @@ class FileSystem : public IFileSystem
{
}

~FileSystem() override
{
}
~FileSystem() override = default;

int mount() override;

Expand Down Expand Up @@ -72,7 +68,7 @@ class FileSystem : public IFileSystem
int flush(FileHandle file) override;
int rename(const char* oldpath, const char* newpath) override;
int remove(const char* path) override;
int fremove(FileHandle file) override
int fremove(FileHandle) override
{
return Error::NotImplemented;
}
Expand All @@ -92,5 +88,4 @@ class FileSystem : public IFileSystem
bool mounted;
};

} // namespace Host
} // namespace IFS
} // namespace IFS::Host
2 changes: 1 addition & 1 deletion src/Attribute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ bool fromString(const char* name, IFS::AttributeTag& tag)
{
auto namelen = strlen(name);
if(namelen == 6 && memicmp(name, _F("user"), 4) == 0) {
auto tagIndex = (unhex(name[4]) << 4) | unhex(name[5]);
auto tagIndex = (uint8_t(unhex(name[4])) << 4) | unhex(name[5]);
tag = IFS::AttributeTag(unsigned(IFS::AttributeTag::User) + tagIndex);
return true;
}
Expand Down
7 changes: 2 additions & 5 deletions src/Debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@
#include <IFS/File.h>
#include <IFS/Directory.h>

namespace IFS
{
namespace Debug
namespace IFS::Debug
{
void printFsInfo(Print& out, FileSystem& fs)
{
Expand Down Expand Up @@ -102,5 +100,4 @@ int listDirectory(Print& out, FileSystem& fs, const String& path, Options option
return dir.getLastError();
}

} // namespace Debug
} // namespace IFS
} // namespace IFS::Debug
7 changes: 2 additions & 5 deletions src/Error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
#include <FlashString/String.hpp>
#include <FlashString/Vector.hpp>

namespace IFS
{
namespace Error
namespace IFS::Error
{
/*
* Define string table for standard IFS error codes
Expand Down Expand Up @@ -56,5 +54,4 @@ String toString(int err)
return s;
}

} // namespace Error
} // namespace IFS
} // namespace IFS::Error
21 changes: 9 additions & 12 deletions src/FWFS/ArchiveStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
#include <IFS/FWFS/ArchiveStream.h>
#include <Data/Stream/IFS/FileStream.h>

namespace IFS
{
namespace FWFS
namespace IFS::FWFS
{
constexpr size_t maxInlineSize{255};

Expand All @@ -47,7 +45,7 @@ bool ArchiveStream::fillBuffers()
{
auto gotoEnd = [&]() {
buffer.write(FWFILESYS_END_MARKER);
queueStream(&buffer, State::end);
queueStream(buffer, State::end);
};

switch(state) {
Expand All @@ -56,7 +54,7 @@ bool ArchiveStream::fillBuffers()
volumeInfo.creationTime = fsGetTimeUTC();
}
buffer.write(FWFILESYS_START_MARKER);
queueStream(&buffer, State::start);
queueStream(buffer, State::start);
break;

case State::start:
Expand Down Expand Up @@ -309,7 +307,7 @@ bool ArchiveStream::readFileEntry(const Stat& stat)
// Default behaviour
auto stream = new FileStream(fs);
stream->attach(file, stat.size);
encoder.reset(new BasicEncoder(stream));
encoder = std::make_unique<BasicEncoder>(stream);
}
sendDataHeader();
}
Expand All @@ -334,7 +332,7 @@ void ArchiveStream::sendDataHeader()

buffer.clear();
auto type = buffer.writeDataHeader(size);
queueStream(&buffer, State::dataHeader);
queueStream(buffer, State::dataHeader);

// Add reference to file header
auto& entry = directories[level];
Expand All @@ -357,7 +355,7 @@ void ArchiveStream::sendFileHeader()
encoder.reset();
auto& entry = directories[level];
entry.content->fixupSize();
queueStream(entry.content.get(), State::fileHeader);
queueStream(*entry.content, State::fileHeader);

// Add reference to parent directory
auto& parent = directories[level - 1];
Expand Down Expand Up @@ -445,7 +443,7 @@ void ArchiveStream::closeDirectory()
currentPath.setLength(currentPath.length() - dir.namelen);

dir.content->fixupSize();
queueStream(dir.content.get(), State::dirHeader);
queueStream(*dir.content, State::dirHeader);

// Add entry for this directory to parent
if(level > 0) {
Expand Down Expand Up @@ -475,8 +473,7 @@ void ArchiveStream::getVolume()
hdr.data8.setContentSize(sizeof(uint32_t));
buffer.write(hdr, sizeof(uint32_t), 0);

queueStream(&buffer, State::volumeHeader);
queueStream(buffer, State::volumeHeader);
}

} // namespace FWFS
} // namespace IFS
} // namespace IFS::FWFS
Loading

0 comments on commit a377908

Please sign in to comment.