Skip to content

Commit 8d9db3c

Browse files
committed
Fixes issue #181.
1 parent aae269e commit 8d9db3c

File tree

6 files changed

+72
-34
lines changed

6 files changed

+72
-34
lines changed

project/qtcreator-osx/efsw.creator.user

+21-27
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!DOCTYPE QtCreatorProject>
3-
<!-- Written by QtCreator 7.0.2, 2022-06-19T12:14:51. -->
3+
<!-- Written by QtCreator 12.0.1, 2024-09-03T01:51:40. -->
44
<qtcreator>
55
<data>
66
<variable>EnvironmentId</variable>
7-
<value type="QByteArray">{1e2eacf3-3fa1-45d9-bcd5-871df4d12ee9}</value>
7+
<value type="QByteArray">{49267ae2-f136-4b84-8041-cf11a20f6a32}</value>
88
</data>
99
<data>
1010
<variable>ProjectExplorer.Project.ActiveTarget</variable>
@@ -37,6 +37,7 @@
3737
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
3838
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
3939
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
40+
<value type="int" key="EditorConfiguration.PreferAfterWhitespaceComments">0</value>
4041
<value type="bool" key="EditorConfiguration.PreferSingleLineComments">false</value>
4142
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
4243
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
@@ -54,6 +55,7 @@
5455
<value type="QString" key="EditorConfiguration.ignoreFileTypes">*.md, *.MD, Makefile</value>
5556
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
5657
<value type="bool" key="EditorConfiguration.skipTrailingWhitespace">true</value>
58+
<value type="bool" key="EditorConfiguration.tintMarginArea">true</value>
5759
</valuemap>
5860
</data>
5961
<data>
@@ -77,6 +79,7 @@
7779
<value type="bool" key="ClangTools.BuildBeforeAnalysis">true</value>
7880
<value type="QString" key="ClangTools.DiagnosticConfig">Builtin.DefaultTidyAndClazy</value>
7981
<value type="int" key="ClangTools.ParallelJobs">4</value>
82+
<value type="bool" key="ClangTools.PreferConfigFile">false</value>
8083
<valuelist type="QVariantList" key="ClangTools.SelectedDirs"/>
8184
<valuelist type="QVariantList" key="ClangTools.SelectedFiles"/>
8285
<valuelist type="QVariantList" key="ClangTools.SuppressedDiagnostics"/>
@@ -88,9 +91,9 @@
8891
<variable>ProjectExplorer.Project.Target.0</variable>
8992
<valuemap type="QVariantMap">
9093
<value type="QString" key="DeviceType">Desktop</value>
91-
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
92-
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
93-
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{03ce7d1a-f943-45a1-9d10-661febc7fb89}</value>
94+
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop (arm-darwin-generic-mach_o-64bit)</value>
95+
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop (arm-darwin-generic-mach_o-64bit)</value>
96+
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{6d6b6d62-1e99-4e76-b5e2-cf731a0dbd92}</value>
9497
<value type="qlonglong" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
9598
<value type="qlonglong" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
9699
<value type="qlonglong" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
@@ -99,13 +102,12 @@
99102
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
100103
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
101104
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
102-
<value type="QString" key="ProjectExplorer.ProcessStep.Arguments">--file=../../premake4.lua --thread-sanitizer gmake</value>
105+
<value type="QString" key="ProjectExplorer.ProcessStep.Arguments">--file=../../premake4.lua --thread-sanitizer --verbose gmake</value>
103106
<value type="QString" key="ProjectExplorer.ProcessStep.Command">/usr/local/bin/premake4</value>
104107
<value type="QString" key="ProjectExplorer.ProcessStep.WorkingDirectory">%{buildDir}</value>
105108
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.ProcessStep</value>
106109
</valuemap>
107110
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
108-
<valuelist type="QVariantList" key="GenericProjectManager.GenericMakeStep.BuildTargets"/>
109111
<value type="QString" key="GenericProjectManager.GenericMakeStep.MakeArguments">-j4</value>
110112
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
111113
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">GenericProjectManager.GenericMakeStep</value>
@@ -147,7 +149,6 @@
147149
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.ProcessStep</value>
148150
</valuemap>
149151
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
150-
<valuelist type="QVariantList" key="GenericProjectManager.GenericMakeStep.BuildTargets"/>
151152
<value type="QString" key="GenericProjectManager.GenericMakeStep.MakeArguments">-j4 config=release</value>
152153
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
153154
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">GenericProjectManager.GenericMakeStep</value>
@@ -194,49 +195,42 @@
194195
</valuemap>
195196
<value type="qlonglong" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
196197
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
197-
<value type="QString" key="Analyzer.Perf.CallgraphMode">dwarf</value>
198-
<valuelist type="QVariantList" key="Analyzer.Perf.Events">
199-
<value type="QString">cpu-cycles</value>
200-
</valuelist>
201-
<value type="QString" key="Analyzer.Perf.SampleMode">-F</value>
202198
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
203-
<value type="uint" key="Analyzer.QmlProfiler.FlushInterval">0</value>
199+
<value type="qlonglong" key="Analyzer.QmlProfiler.FlushInterval">0</value>
204200
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
205201
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
206202
<valuelist type="QVariantList" key="CustomOutputParsers"/>
207203
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
208204
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
209-
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable">efsw-test-debug</value>
205+
<value type="bool" key="PE.EnvironmentAspect.PrintOnRun">false</value>
206+
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable">/Users/prognoz/programming/efsw/bin/efsw-test-debug</value>
210207
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">debug</value>
211208
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
212209
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey"></value>
213-
<value type="bool" key="RunConfiguration.UseCppDebugger">true</value>
210+
<value type="bool" key="ProjectExplorer.RunConfiguration.Customized">true</value>
211+
<value type="int" key="RunConfiguration.UseCppDebugger">0</value>
214212
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">false</value>
215-
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
216-
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
213+
<value type="int" key="RunConfiguration.UseQmlDebugger">1</value>
214+
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">false</value>
217215
<value type="bool" key="RunConfiguration.UseTerminal">false</value>
218-
<value type="QString" key="RunConfiguration.WorkingDirectory">%{buildDir}/../../bin/</value>
216+
<value type="QString" key="RunConfiguration.WorkingDirectory">%{buildDir}/../../bin</value>
219217
</valuemap>
220218
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.1">
221-
<value type="QString" key="Analyzer.Perf.CallgraphMode">dwarf</value>
222-
<valuelist type="QVariantList" key="Analyzer.Perf.Events">
223-
<value type="QString">cpu-cycles</value>
224-
</valuelist>
225-
<value type="QString" key="Analyzer.Perf.SampleMode">-F</value>
226219
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
227-
<value type="uint" key="Analyzer.QmlProfiler.FlushInterval">0</value>
220+
<value type="qlonglong" key="Analyzer.QmlProfiler.FlushInterval">0</value>
228221
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
229222
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
230223
<valuelist type="QVariantList" key="CustomOutputParsers"/>
231224
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
232225
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
226+
<value type="bool" key="PE.EnvironmentAspect.PrintOnRun">false</value>
233227
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable">efsw-test</value>
234228
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">release</value>
235229
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
236230
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey"></value>
237-
<value type="bool" key="RunConfiguration.UseCppDebugger">true</value>
231+
<value type="bool" key="ProjectExplorer.RunConfiguration.Customized">false</value>
232+
<value type="int" key="RunConfiguration.UseCppDebugger">1</value>
238233
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">false</value>
239-
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
240234
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
241235
<value type="bool" key="RunConfiguration.UseTerminal">false</value>
242236
<value type="QString" key="RunConfiguration.WorkingDirectory">%{buildDir}/../../bin/</value>

src/efsw/FileSystem.hpp

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
#include <efsw/FileInfo.hpp>
55
#include <efsw/base.hpp>
6-
#include <map>
76

87
namespace efsw {
98

src/efsw/FileWatcherFSEvents.cpp

+41-2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,32 @@ bool FileWatcherFSEvents::isGranular() {
4141
return getOSXReleaseNumber() >= 11;
4242
}
4343

44+
static std::string convertCFStringToStdString( CFStringRef cfString ) {
45+
// Try to get the C string pointer directly
46+
const char* cStr = CFStringGetCStringPtr( cfString, kCFStringEncodingUTF8 );
47+
48+
if ( cStr ) {
49+
// If the pointer is valid, directly return a std::string from it
50+
return std::string( cStr );
51+
} else {
52+
// If not, manually convert it
53+
CFIndex length = CFStringGetLength( cfString );
54+
CFIndex maxSize = CFStringGetMaximumSizeForEncoding( length, kCFStringEncodingUTF8 ) +
55+
1; // +1 for null terminator
56+
57+
char* buffer = new char[maxSize];
58+
59+
if ( CFStringGetCString( cfString, buffer, maxSize, kCFStringEncodingUTF8 ) ) {
60+
std::string result( buffer );
61+
delete[] buffer;
62+
return result;
63+
} else {
64+
delete[] buffer;
65+
return "";
66+
}
67+
}
68+
}
69+
4470
void FileWatcherFSEvents::FSEventCallback( ConstFSEventStreamRef streamRef, void* userData,
4571
size_t numEvents, void* eventPaths,
4672
const FSEventStreamEventFlags eventFlags[],
@@ -51,8 +77,21 @@ void FileWatcherFSEvents::FSEventCallback( ConstFSEventStreamRef streamRef, void
5177
events.reserve( numEvents );
5278

5379
for ( size_t i = 0; i < numEvents; i++ ) {
54-
events.push_back( FSEvent( std::string( ( (char**)eventPaths )[i] ), (long)eventFlags[i],
55-
(Uint64)eventIds[i] ) );
80+
if ( isGranular() ) {
81+
CFDictionaryRef pathInfoDict =
82+
static_cast<CFDictionaryRef>( CFArrayGetValueAtIndex( (CFArrayRef)eventPaths, i ) );
83+
CFStringRef path = static_cast<CFStringRef>(
84+
CFDictionaryGetValue( pathInfoDict, kFSEventStreamEventExtendedDataPathKey ) );
85+
CFNumberRef cfInode = static_cast<CFNumberRef>(
86+
CFDictionaryGetValue( pathInfoDict, kFSEventStreamEventExtendedFileIDKey ) );
87+
unsigned long inode = 0;
88+
CFNumberGetValue( cfInode, kCFNumberLongType, &inode );
89+
events.push_back( FSEvent( convertCFStringToStdString( path ), (long)eventFlags[i],
90+
(Uint64)eventIds[i], inode ) );
91+
} else {
92+
events.push_back( FSEvent( std::string( ( (char**)eventPaths )[i] ),
93+
(long)eventFlags[i], (Uint64)eventIds[i] ) );
94+
}
5695
}
5796

5897
watcher->handleActions( events );

src/efsw/FileWatcherFSEvents.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ namespace efsw {
1919
/* OSX < 10.7 has no file events */
2020
/* So i declare the events constants */
2121
enum FSEventEvents {
22+
efswFSEventStreamCreateFlagUseCFTypes = 0x00000001,
2223
efswFSEventStreamCreateFlagNoDefer = 0x00000002,
2324
efswFSEventStreamCreateFlagFileEvents = 0x00000010,
25+
efswFSEventStreamCreateFlagUseExtendedData = 0x00000040,
2426
efswFSEventStreamEventFlagItemCreated = 0x00000100,
2527
efswFSEventStreamEventFlagItemRemoved = 0x00000200,
2628
efswFSEventStreamEventFlagItemInodeMetaMod = 0x00000400,

src/efsw/WatcherFSEvents.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ void WatcherFSEvents::init() {
3535
Uint32 streamFlags = kFSEventStreamCreateFlagNone;
3636

3737
if ( FileWatcherFSEvents::isGranular() ) {
38-
streamFlags = efswFSEventStreamCreateFlagFileEvents | efswFSEventStreamCreateFlagNoDefer;
38+
streamFlags = efswFSEventStreamCreateFlagFileEvents | efswFSEventStreamCreateFlagNoDefer |
39+
efswFSEventStreamCreateFlagUseExtendedData |
40+
efswFSEventStreamCreateFlagUseCFTypes;
3941
} else {
4042
WatcherGen = new WatcherGeneric( ID, Directory, Listener, FWatcher.load(), Recursive );
4143
}
@@ -128,12 +130,12 @@ void WatcherFSEvents::handleActions( std::vector<FSEvent>& events ) {
128130
// been added modified and erased, but i can't know if first was erased and then added
129131
// and modified, or added, then modified and then erased. I don't know what they were
130132
// thinking by doing this...
131-
efDEBUG( "Event in: %s - flags: %ld\n", event.Path.c_str(), event.Flags );
133+
efDEBUG( "Event in: %s - flags: 0x%x\n", event.Path.c_str(), event.Flags );
132134

133135
if ( event.Flags & efswFSEventStreamEventFlagItemRenamed ) {
134136
if ( ( i + 1 < esize ) &&
135137
( events[i + 1].Flags & efswFSEventStreamEventFlagItemRenamed ) &&
136-
( events[i + 1].Id == event.Id + 1 ) ) {
138+
( events[i + 1].inode == event.inode ) ) {
137139
FSEvent& nEvent = events[i + 1];
138140
std::string newDir( FileSystem::pathRemoveFileName( nEvent.Path ) );
139141
std::string newFilepath( FileSystem::fileNameFromPath( nEvent.Path ) );

src/efsw/WatcherFSEvents.hpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ class FileWatcherFSEvents;
1818

1919
class FSEvent {
2020
public:
21-
FSEvent( std::string path, long flags, Uint64 id ) : Path( path ), Flags( flags ), Id( id ) {}
21+
FSEvent( std::string path, long flags, Uint64 id, Uint64 inode = 0 ) :
22+
Path( path ), Flags( flags ), Id( id ), inode( inode ) {}
2223

2324
std::string Path;
2425
long Flags;
2526
Uint64 Id;
27+
Uint64 inode{ 0 };
2628
};
2729

2830
class WatcherFSEvents : public Watcher {

0 commit comments

Comments
 (0)