@@ -147,13 +147,6 @@ void fossil_sys_call_exit(int exit_code);
147147 */
148148int fossil_sys_call_execute_capture (const char *command, char *buffer, size_t size);
149149
150- /* *
151- * @brief Get the parent process ID.
152- *
153- * @return PID of the parent process.
154- */
155- int fossil_sys_call_getppid (void );
156-
157150#ifdef __cplusplus
158151}
159152#include < string>
@@ -173,17 +166,6 @@ namespace fossil {
173166 */
174167 class Syscall {
175168 public:
176-
177- /* *
178- * Execute a system command.
179- *
180- * @param command The command to execute.
181- * @return The return value of the system command.
182- */
183- static int execute (const char *command) {
184- return fossil_sys_call_execute (command);
185- }
186-
187169 /* *
188170 * Execute a system command.
189171 *
@@ -218,18 +200,123 @@ namespace fossil {
218200 * @param filename The name of the file to create.
219201 * @return 0 on success, or a negative error code on failure.
220202 */
221- static int create_file (const char * filename) {
222- return fossil_sys_call_create_file (filename);
203+ static int create_file (const std::string & filename) {
204+ return fossil_sys_call_create_file (filename. c_str () );
223205 }
224206
225207 /* *
226- * Create a new file.
208+ * Delete a file.
227209 *
228- * @param filename The name of the file to create .
229- * @return 0 on success, or a negative error code on failure.
210+ * @param filename Path to the file to delete .
211+ * @return 0 on success, negative error code on failure.
230212 */
231- static int create_file (const std::string &filename) {
232- return fossil_sys_call_create_file (filename.c_str ());
213+ static int delete_file (const std::string &filename) {
214+ return fossil_sys_call_delete_file (filename.c_str ());
215+ }
216+
217+ /* *
218+ * Check if a file exists.
219+ *
220+ * @param filename Path to the file.
221+ * @return 1 if the file exists, 0 if not.
222+ */
223+ static int file_exists (const std::string &filename) {
224+ return fossil_sys_call_file_exists (filename.c_str ());
225+ }
226+
227+ /* *
228+ * Create a directory.
229+ *
230+ * @param dirname Path of the directory to create.
231+ * @return 0 on success, negative error code on failure.
232+ */
233+ static int create_directory (const std::string &dirname) {
234+ return fossil_sys_call_create_directory (dirname.c_str ());
235+ }
236+
237+ /* *
238+ * Delete a directory (optionally recursive).
239+ *
240+ * @param dirname Path of the directory to delete.
241+ * @param recursive If non-zero, delete all contents recursively.
242+ * @return 0 on success, negative error code on failure.
243+ */
244+ static int delete_directory (const std::string &dirname, int recursive) {
245+ return fossil_sys_call_delete_directory (dirname.c_str (), recursive);
246+ }
247+
248+ /* *
249+ * Get the current working directory.
250+ *
251+ * @param buffer Buffer to receive the current path.
252+ * @param size Size of the buffer.
253+ * @return 0 on success, negative error code on failure.
254+ */
255+ static int getcwd (std::string *buffer, size_t size) {
256+ return fossil_sys_call_getcwd (buffer->data (), size);
257+ }
258+
259+ /* *
260+ * Change the current working directory.
261+ *
262+ * @param path Path to set as current working directory.
263+ * @return 0 on success, negative error code on failure.
264+ */
265+ static int chdir (const std::string &path) {
266+ return fossil_sys_call_chdir (path.c_str ());
267+ }
268+
269+ /* *
270+ * List files in a directory.
271+ *
272+ * @param dirname Path to the directory.
273+ * @param out_list Pointer to array of strings (allocated by function).
274+ * @param out_count Pointer to receive the number of entries.
275+ * @return 0 on success, negative error code on failure.
276+ */
277+ static int list_directory (const std::string &dirname, char ***out_list, size_t *out_count) {
278+ return fossil_sys_call_list_directory (dirname.c_str (), out_list, out_count);
279+ }
280+
281+ /* *
282+ * Check if a path is a directory.
283+ *
284+ * @param path Path to check.
285+ * @return 1 if directory, 0 if not.
286+ */
287+ static int is_directory (const std::string &path) {
288+ return fossil_sys_call_is_directory (path.c_str ());
289+ }
290+
291+ /* *
292+ * Check if a path is a regular file.
293+ *
294+ * @param path Path to check.
295+ * @return 1 if regular file, 0 if not.
296+ */
297+ static int is_file (const std::string &path) {
298+ return fossil_sys_call_is_file (path.c_str ());
299+ }
300+
301+ /* *
302+ * Terminate the current process.
303+ *
304+ * @param exit_code Exit code to return to the operating system.
305+ */
306+ static void exit (int exit_code) {
307+ fossil_sys_call_exit (exit_code);
308+ }
309+
310+ /* *
311+ * Execute a command and capture output.
312+ *
313+ * @param command Command string to execute.
314+ * @param buffer Buffer to store output.
315+ * @param size Size of the buffer.
316+ * @return 0 on success, negative error code on failure.
317+ */
318+ static int execute_capture (const std::string &command, std::string *buffer) {
319+ return fossil_sys_call_execute_capture (command.c_str (), buffer->data (), buffer->size ());
233320 }
234321
235322 };
0 commit comments