schedsvc: Load job files at the service start up.

Signed-off-by: Dmitry Timoshkov <dmitry@baikal.ru>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Dmitry Timoshkov 2018-06-08 15:43:51 +08:00 committed by Alexandre Julliard
parent 58afce6a38
commit ae79454989
3 changed files with 44 additions and 0 deletions

View File

@ -623,6 +623,47 @@ void add_job(const WCHAR *name)
LeaveCriticalSection(&at_job_list_section); LeaveCriticalSection(&at_job_list_section);
} }
static inline BOOL is_file(const WIN32_FIND_DATAW *data)
{
return !(data->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY);
}
void load_at_tasks(void)
{
static const WCHAR tasksW[] = { '\\','T','a','s','k','s','\\',0 };
static const WCHAR allW[] = { '*',0 };
WCHAR windir[MAX_PATH], path[MAX_PATH];
WIN32_FIND_DATAW data;
HANDLE handle;
GetWindowsDirectoryW(windir, MAX_PATH);
lstrcpyW(path, windir);
lstrcatW(path, tasksW);
lstrcatW(path, allW);
handle = FindFirstFileW(path, &data);
if (handle == INVALID_HANDLE_VALUE) return;
do
{
if (is_file(&data))
{
lstrcpyW(path, windir);
lstrcatW(path, tasksW);
if (lstrlenW(path) + lstrlenW(data.cFileName) < MAX_PATH)
{
lstrcatW(path, data.cFileName);
add_job(path);
}
else
FIXME("too long file name %s\n", debugstr_w(data.cFileName));
}
} while (FindNextFileW(handle, &data));
FindClose(handle);
}
static BOOL write_signature(HANDLE hfile) static BOOL write_signature(HANDLE hfile)
{ {
struct struct

View File

@ -30,6 +30,7 @@ void add_process_to_queue(HANDLE hproc) DECLSPEC_HIDDEN;
void update_process_status(DWORD pid) DECLSPEC_HIDDEN; void update_process_status(DWORD pid) DECLSPEC_HIDDEN;
BOOL get_next_runtime(LARGE_INTEGER *rt) DECLSPEC_HIDDEN; BOOL get_next_runtime(LARGE_INTEGER *rt) DECLSPEC_HIDDEN;
void check_task_time(void) DECLSPEC_HIDDEN; void check_task_time(void) DECLSPEC_HIDDEN;
void load_at_tasks(void) DECLSPEC_HIDDEN;
static inline WCHAR *heap_strdupW(const WCHAR *src) static inline WCHAR *heap_strdupW(const WCHAR *src)
{ {

View File

@ -53,6 +53,8 @@ static DWORD WINAPI tasks_monitor_thread(void *arg)
TRACE("Starting...\n"); TRACE("Starting...\n");
load_at_tasks();
htimer = CreateWaitableTimerW(NULL, FALSE, NULL); htimer = CreateWaitableTimerW(NULL, FALSE, NULL);
if (htimer == NULL) if (htimer == NULL)
{ {