Hi,
The root of our problem was that the MEF library called console commands for manipulating a file system which caused the Windows command-line windows to pop open. This is a standard Windows behavior which is very hard to suppress without dirty hacks. Therefore my proposal is to call operating system API for manipulating the file system rather than console commands.
Since the OS APIs are different for each operating system, I created a new module which wraps both Windows and POSIX calls. Therefore it is useable on both Mac and Windows. The module and its header (fileutils.c and fileutils.h) are attached as well as the changed meflib.c. All calls to ‘system’ function were replaced by appropriate functions from the fileutils module.
Do you think this change could be incorporated into the MEF library code, please?
There are 4 changes we suggest to be implemented in meflib.c. Short summary follows and I attached a diff file from our versioning system as well in case it helps.
Line 39 (in the attached version)
// written with tab width = indent width = 8 spaces and a monospaced font
// set editor preferences to these for intended alignment
if (fps->fp == NULL && errno == ENOENT) {
// A component of the required directory tree does not exist - build it & try again
extract_path_parts(fps->full_file_name, path, name, extension);
file_utils_make_directory(path);
fps->fp = e_fopen(fps->full_file_name, mode, function, line, behavior_on_fail);
}
Since variable ‘command’ is no longer used in this function, I removed it as well.
Line 3886 (function generate_file_list)
// free previous file list
if (file_list != NULL) {
for (i = 0; i < *num_files; ++i)
free(file_list[i]);
free(file_list);
}
// create unique junk file - avoids conflicts when runnig multiple processes which fight for the same file access
unique_junk = tmpnam(NULL);
file_utils_list_directory_to_file(enclosing_directory, extension, unique_junk);
fp = e_fopen(unique_junk, "r", __FUNCTION__, __LINE__, USE_GLOBAL_BEHAVIOR);
*num_files = 0;
while ((fscanf(fp, "%s", temp_str)) != EOF)
++(*num_files);
Line 3910 (function generate_file_list)
// build file list
rewind(fp);
//WINCHANGE
for (i = 0; i < *num_files; ++i){
fscanf(fp, "%s",temp_str);
sprintf(file_list[i],"%s/%s",enclosing_directory,temp_str);
}
// clean up
fclose(fp);
file_utils_delete_file(unique_junk);
return(file_list);
Hi, The root of our problem was that the MEF library called console commands for manipulating a file system which caused the Windows command-line windows to pop open. This is a standard Windows behavior which is very hard to suppress without dirty hacks. Therefore my proposal is to call operating system API for manipulating the file system rather than console commands.
Since the OS APIs are different for each operating system, I created a new module which wraps both Windows and POSIX calls. Therefore it is useable on both Mac and Windows. The module and its header (fileutils.c and fileutils.h) are attached as well as the changed meflib.c. All calls to ‘system’ function were replaced by appropriate functions from the fileutils module.
Do you think this change could be incorporated into the MEF library code, please? There are 4 changes we suggest to be implemented in meflib.c. Short summary follows and I attached a diff file from our versioning system as well in case it helps.
Line 39 (in the attached version)
// written with tab width = indent width = 8 spaces and a monospaced font
// set editor preferences to these for intended alignment
include "stdafx.h"
include "fileutils.h"
// global
Line 3592 (function fps_open)
fps->fp = e_fopen(fps->full_file_name, mode, function, line, RETURN_ON_FAIL | SUPPRESS_ERROR_OUTPUT);
Since variable ‘command’ is no longer used in this function, I removed it as well.
Line 3886 (function generate_file_list)
Line 3910 (function generate_file_list)
Here is the diff file and modified meflib.c file: diff and meflib.zip