Skip to content

Commit a377908

Browse files
committed
Merge branch 'develop'
2 parents c564d2c + 4437e76 commit a377908

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+520
-239
lines changed

.github/workflows/ci-dispatch.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: CI Dispatch
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
sming_repo:
7+
description: 'Full URL for Sming repository'
8+
default: 'https://github.com/SmingHub/Sming'
9+
type: string
10+
sming_branch:
11+
description: 'Sming branch to run against'
12+
default: 'develop'
13+
type: string
14+
15+
jobs:
16+
build:
17+
uses: SmingHub/Sming/.github/workflows/library.yml@develop
18+
with:
19+
sming_repo: ${{ inputs.sming_repo }}
20+
sming_branch: ${{ inputs.sming_branch }}

.github/workflows/ci-push.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
name: CI Push
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
uses: SmingHub/Sming/.github/workflows/library.yml@develop

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,8 @@ Such a system would require almost no static RAM allocation and code size would
254254

255255

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

260260

261261
.. note::

src/Arch/Host/FileSystem.cpp

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
*
2020
****/
2121

22-
#define _POSIX_C_SOURCE 200112L
23-
2422
#include <IFS/Host/FileSystem.h>
2523
#include <IFS/Host/Util.h>
2624
#include <IFS/Util.h>
@@ -65,6 +63,9 @@ namespace Host
6563
#ifdef __WIN32
6664
struct os_stat_t : public ::_stati64 {
6765
};
66+
#elif defined(__APPLE__)
67+
struct os_stat_t : public ::stat {
68+
};
6869
#else
6970
struct os_stat_t : public ::stat64 {
7071
};
@@ -88,7 +89,7 @@ const char* extendedAttributePrefix{"user.ifs."};
8889

8990
int setXAttr(FileHandle file, const char* name, const void* value, size_t size)
9091
{
91-
#if defined(__MACOS)
92+
#if defined(__APPLE__)
9293
int res = ::fsetxattr(file, name, value, size, 0, 0);
9394
#else
9495
int res = ::fsetxattr(file, name, value, size, 0);
@@ -98,7 +99,7 @@ int setXAttr(FileHandle file, const char* name, const void* value, size_t size)
9899

99100
int getXAttr(FileHandle file, const char* name, void* value, size_t size)
100101
{
101-
#if defined(__MACOS)
102+
#if defined(__APPLE__)
102103
auto len = ::fgetxattr(file, name, value, size, 0, 0);
103104
#else
104105
auto len = ::fgetxattr(file, name, value, size);
@@ -108,7 +109,7 @@ int getXAttr(FileHandle file, const char* name, void* value, size_t size)
108109

109110
int listXAttr(FileHandle file, char* namebuf, size_t size)
110111
{
111-
#if defined(__MACOS)
112+
#if defined(__APPLE__)
112113
auto len = ::flistxattr(file, namebuf, size, 0);
113114
#else
114115
auto len = ::flistxattr(file, namebuf, size);
@@ -191,8 +192,10 @@ int settime(const char* path, TimeStamp mtime)
191192
_utimbuf times{mtime, mtime};
192193
int res = _utime(path, &times);
193194
#else
194-
struct utimbuf times[]{mtime, mtime};
195-
int res = ::utime(path, times);
195+
struct utimbuf times {
196+
mtime, mtime
197+
};
198+
int res = ::utime(path, &times);
196199
#endif
197200
return (res >= 0) ? res : syserr();
198201
}
@@ -216,7 +219,7 @@ int FileSystem::mount()
216219
int res = ::stat(rootpath.c_str(), &s);
217220
if(res < 0) {
218221
res = syserr();
219-
debug_e("[FS] Mount '%s' failed, %s", rootpath.c_str(), getErrorString(res));
222+
debug_e("[FS] Mount '%s' failed, %s", rootpath.c_str(), getErrorString(res).c_str());
220223
return res;
221224
}
222225
if(!S_ISDIR(s.st_mode)) {
@@ -360,7 +363,11 @@ int FileSystem::stat(const char* path, Stat* stat)
360363
String fullpath = resolvePath(path);
361364

362365
os_stat_t s;
366+
#ifdef __APPLE__
367+
int res = ::stat(fullpath.c_str(), &s);
368+
#else
363369
int res = ::stat64(fullpath.c_str(), &s);
370+
#endif
364371
if(res < 0) {
365372
return syserr();
366373
}
@@ -384,7 +391,11 @@ int FileSystem::fstat(FileHandle file, Stat* stat)
384391
CHECK_MOUNTED()
385392

386393
os_stat_t s;
394+
#ifdef __APPLE__
395+
int res = ::fstat(file, &s);
396+
#else
387397
int res = ::fstat64(file, &s);
398+
#endif
388399
if(res < 0) {
389400
return syserr();
390401
}
@@ -608,7 +619,11 @@ file_offset_t FileSystem::lseek(FileHandle file, file_offset_t offset, SeekOrigi
608619
{
609620
CHECK_MOUNTED()
610621

622+
#ifdef __APPLE__
623+
auto res = ::lseek(file, offset, uint8_t(origin));
624+
#else
611625
auto res = ::lseek64(file, offset, uint8_t(origin));
626+
#endif
612627
if(res < 0) {
613628
return syserr();
614629
}
@@ -632,7 +647,11 @@ int FileSystem::eof(FileHandle file)
632647
}
633648

634649
os_stat_t stat;
650+
#ifdef __APPLE__
651+
int err = ::fstat(file, &stat);
652+
#else
635653
int err = ::fstat64(file, &stat);
654+
#endif
636655
if(err < 0) {
637656
return syserr();
638657
}
@@ -649,7 +668,11 @@ int FileSystem::ftruncate(FileHandle file, file_size_t new_size)
649668
{
650669
CHECK_MOUNTED()
651670

671+
#ifdef __APPLE__
672+
int res = ::ftruncate(file, new_size);
673+
#else
652674
int res = ::ftruncate64(file, new_size);
675+
#endif
653676
return (res >= 0) ? res : syserr();
654677
}
655678

src/Arch/Host/Windows/xattr.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ namespace
2929
constexpr size_t nameSize{32};
3030
constexpr size_t contentSize{1024};
3131

32-
NTSTATUS getExtendedAttribute(HANDLE hFile, const char* name, void* buffer, size_t bufSize, size_t& length)
32+
NTSTATUS getExtendedAttribute(HANDLE hFile, const char* name, void* buffer, size_t& length)
3333
{
3434
char buf[sizeof(FILE_FULL_EA_INFORMATION) + nameSize + contentSize];
3535
auto get = reinterpret_cast<FILE_GET_EA_INFORMATION*>(buf);
@@ -147,7 +147,7 @@ int fgetxattr(int file, const char* name, void* value, size_t size)
147147
{
148148
EaBuffer buffer(name);
149149
size_t length;
150-
auto status = getExtendedAttribute(getHandle(file), buffer.name, buffer.content, contentSize, length);
150+
auto status = getExtendedAttribute(getHandle(file), buffer.name, buffer.content, length);
151151
errno = getErrno(status);
152152
if(status != STATUS_SUCCESS) {
153153
return -1;

src/Arch/Host/include/IFS/Host/FileSystem.h

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@
2424

2525
#include <IFS/IFileSystem.h>
2626

27-
namespace IFS
28-
{
29-
namespace Host
27+
namespace IFS::Host
3028
{
3129
struct os_stat_t;
3230

@@ -40,9 +38,7 @@ class FileSystem : public IFileSystem
4038
{
4139
}
4240

43-
~FileSystem() override
44-
{
45-
}
41+
~FileSystem() override = default;
4642

4743
int mount() override;
4844

@@ -72,7 +68,7 @@ class FileSystem : public IFileSystem
7268
int flush(FileHandle file) override;
7369
int rename(const char* oldpath, const char* newpath) override;
7470
int remove(const char* path) override;
75-
int fremove(FileHandle file) override
71+
int fremove(FileHandle) override
7672
{
7773
return Error::NotImplemented;
7874
}
@@ -92,5 +88,4 @@ class FileSystem : public IFileSystem
9288
bool mounted;
9389
};
9490

95-
} // namespace Host
96-
} // namespace IFS
91+
} // namespace IFS::Host

src/Attribute.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ bool fromString(const char* name, IFS::AttributeTag& tag)
6767
{
6868
auto namelen = strlen(name);
6969
if(namelen == 6 && memicmp(name, _F("user"), 4) == 0) {
70-
auto tagIndex = (unhex(name[4]) << 4) | unhex(name[5]);
70+
auto tagIndex = (uint8_t(unhex(name[4])) << 4) | unhex(name[5]);
7171
tag = IFS::AttributeTag(unsigned(IFS::AttributeTag::User) + tagIndex);
7272
return true;
7373
}

src/Debug.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@
2121
#include <IFS/File.h>
2222
#include <IFS/Directory.h>
2323

24-
namespace IFS
25-
{
26-
namespace Debug
24+
namespace IFS::Debug
2725
{
2826
void printFsInfo(Print& out, FileSystem& fs)
2927
{
@@ -102,5 +100,4 @@ int listDirectory(Print& out, FileSystem& fs, const String& path, Options option
102100
return dir.getLastError();
103101
}
104102

105-
} // namespace Debug
106-
} // namespace IFS
103+
} // namespace IFS::Debug

src/Error.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@
2424
#include <FlashString/String.hpp>
2525
#include <FlashString/Vector.hpp>
2626

27-
namespace IFS
28-
{
29-
namespace Error
27+
namespace IFS::Error
3028
{
3129
/*
3230
* Define string table for standard IFS error codes
@@ -56,5 +54,4 @@ String toString(int err)
5654
return s;
5755
}
5856

59-
} // namespace Error
60-
} // namespace IFS
57+
} // namespace IFS::Error

src/FWFS/ArchiveStream.cpp

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@
2020
#include <IFS/FWFS/ArchiveStream.h>
2121
#include <Data/Stream/IFS/FileStream.h>
2222

23-
namespace IFS
24-
{
25-
namespace FWFS
23+
namespace IFS::FWFS
2624
{
2725
constexpr size_t maxInlineSize{255};
2826

@@ -47,7 +45,7 @@ bool ArchiveStream::fillBuffers()
4745
{
4846
auto gotoEnd = [&]() {
4947
buffer.write(FWFILESYS_END_MARKER);
50-
queueStream(&buffer, State::end);
48+
queueStream(buffer, State::end);
5149
};
5250

5351
switch(state) {
@@ -56,7 +54,7 @@ bool ArchiveStream::fillBuffers()
5654
volumeInfo.creationTime = fsGetTimeUTC();
5755
}
5856
buffer.write(FWFILESYS_START_MARKER);
59-
queueStream(&buffer, State::start);
57+
queueStream(buffer, State::start);
6058
break;
6159

6260
case State::start:
@@ -309,7 +307,7 @@ bool ArchiveStream::readFileEntry(const Stat& stat)
309307
// Default behaviour
310308
auto stream = new FileStream(fs);
311309
stream->attach(file, stat.size);
312-
encoder.reset(new BasicEncoder(stream));
310+
encoder = std::make_unique<BasicEncoder>(stream);
313311
}
314312
sendDataHeader();
315313
}
@@ -334,7 +332,7 @@ void ArchiveStream::sendDataHeader()
334332

335333
buffer.clear();
336334
auto type = buffer.writeDataHeader(size);
337-
queueStream(&buffer, State::dataHeader);
335+
queueStream(buffer, State::dataHeader);
338336

339337
// Add reference to file header
340338
auto& entry = directories[level];
@@ -357,7 +355,7 @@ void ArchiveStream::sendFileHeader()
357355
encoder.reset();
358356
auto& entry = directories[level];
359357
entry.content->fixupSize();
360-
queueStream(entry.content.get(), State::fileHeader);
358+
queueStream(*entry.content, State::fileHeader);
361359

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

447445
dir.content->fixupSize();
448-
queueStream(dir.content.get(), State::dirHeader);
446+
queueStream(*dir.content, State::dirHeader);
449447

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

478-
queueStream(&buffer, State::volumeHeader);
476+
queueStream(buffer, State::volumeHeader);
479477
}
480478

481-
} // namespace FWFS
482-
} // namespace IFS
479+
} // namespace IFS::FWFS

0 commit comments

Comments
 (0)