📄 queue.c
字号:
if (cab_file[0] && cab_file[strlen(cab_file)-1] != '\\') strcat( cab_file, "\\" );
WideCharToMultiByte( CP_ACP, 0, cabinet, -1, cab_file + strlen(cab_file), len, NULL, NULL );
FIXME( "awful hack: extracting cabinet %s\n", debugstr_a(cab_file) );
pExtractFiles( cab_file, cab_path, 0, 0, 0, 0 );
HeapFree( GetProcessHeap(), 0, cab_file );
HeapFree( GetProcessHeap(), 0, cab_path );
return CopyFileW( src, dst, FALSE /*FIXME*/ );
}
/***********************************************************************
* SetupOpenFileQueue (SETUPAPI.@)
*/
HSPFILEQ WINAPI SetupOpenFileQueue(void)
{
struct file_queue *queue;
if (!(queue = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*queue))))
return (HSPFILEQ)INVALID_HANDLE_VALUE;
return queue;
}
/***********************************************************************
* SetupCloseFileQueue (SETUPAPI.@)
*/
BOOL WINAPI SetupCloseFileQueue( HSPFILEQ handle )
{
struct file_queue *queue = handle;
free_file_op_queue( &queue->copy_queue );
free_file_op_queue( &queue->rename_queue );
free_file_op_queue( &queue->delete_queue );
HeapFree( GetProcessHeap(), 0, queue );
return TRUE;
}
/***********************************************************************
* SetupQueueCopyIndirectA (SETUPAPI.@)
*/
BOOL WINAPI SetupQueueCopyIndirectA( PSP_FILE_COPY_PARAMS_A params )
{
struct file_queue *queue = params->QueueHandle;
struct file_op *op;
if (!(op = HeapAlloc( GetProcessHeap(), 0, sizeof(*op) ))) return FALSE;
op->style = params->CopyStyle;
op->src_root = strdupAtoW( params->SourceRootPath );
op->src_path = strdupAtoW( params->SourcePath );
op->src_file = strdupAtoW( params->SourceFilename );
op->src_descr = strdupAtoW( params->SourceDescription );
op->src_tag = strdupAtoW( params->SourceTagfile );
op->dst_path = strdupAtoW( params->TargetDirectory );
op->dst_file = strdupAtoW( params->TargetFilename );
/* some defaults */
if (!op->src_file) op->src_file = op->dst_file;
if (params->LayoutInf)
{
get_src_file_info( params->LayoutInf, op );
if (!op->dst_path) op->dst_path = get_destination_dir( params->LayoutInf, op->dst_file );
}
TRACE( "root=%s path=%s file=%s -> dir=%s file=%s descr=%s tag=%s\n",
debugstr_w(op->src_root), debugstr_w(op->src_path), debugstr_w(op->src_file),
debugstr_w(op->dst_path), debugstr_w(op->dst_file),
debugstr_w(op->src_descr), debugstr_w(op->src_tag) );
queue_file_op( &queue->copy_queue, op );
return TRUE;
}
/***********************************************************************
* SetupQueueCopyIndirectW (SETUPAPI.@)
*/
BOOL WINAPI SetupQueueCopyIndirectW( PSP_FILE_COPY_PARAMS_W params )
{
struct file_queue *queue = params->QueueHandle;
struct file_op *op;
if (!(op = HeapAlloc( GetProcessHeap(), 0, sizeof(*op) ))) return FALSE;
op->style = params->CopyStyle;
op->src_root = strdupW( params->SourceRootPath );
op->src_path = strdupW( params->SourcePath );
op->src_file = strdupW( params->SourceFilename );
op->src_descr = strdupW( params->SourceDescription );
op->src_tag = strdupW( params->SourceTagfile );
op->dst_path = strdupW( params->TargetDirectory );
op->dst_file = strdupW( params->TargetFilename );
op->dst_sd = NULL;
if (params->SecurityDescriptor)
ConvertStringSecurityDescriptorToSecurityDescriptorW( params->SecurityDescriptor, SDDL_REVISION_1, &op->dst_sd, NULL );
/* some defaults */
if (!op->src_file) op->src_file = op->dst_file;
if (params->LayoutInf)
{
get_src_file_info( params->LayoutInf, op );
if (!op->dst_path) op->dst_path = get_destination_dir( params->LayoutInf, op->dst_file );
}
TRACE( "root=%s path=%s file=%s -> dir=%s file=%s descr=%s tag=%s\n",
debugstr_w(op->src_root), debugstr_w(op->src_path), debugstr_w(op->src_file),
debugstr_w(op->dst_path), debugstr_w(op->dst_file),
debugstr_w(op->src_descr), debugstr_w(op->src_tag) );
queue_file_op( &queue->copy_queue, op );
return TRUE;
}
/***********************************************************************
* SetupQueueCopyA (SETUPAPI.@)
*/
BOOL WINAPI SetupQueueCopyA( HSPFILEQ queue, PCSTR src_root, PCSTR src_path, PCSTR src_file,
PCSTR src_descr, PCSTR src_tag, PCSTR dst_dir, PCSTR dst_file,
DWORD style )
{
SP_FILE_COPY_PARAMS_A params;
params.cbSize = sizeof(params);
params.QueueHandle = queue;
params.SourceRootPath = src_root;
params.SourcePath = src_path;
params.SourceFilename = src_file;
params.SourceDescription = src_descr;
params.SourceTagfile = src_tag;
params.TargetDirectory = dst_dir;
params.TargetFilename = dst_file;
params.CopyStyle = style;
params.LayoutInf = 0;
params.SecurityDescriptor = NULL;
return SetupQueueCopyIndirectA( ¶ms );
}
/***********************************************************************
* SetupQueueCopyW (SETUPAPI.@)
*/
BOOL WINAPI SetupQueueCopyW( HSPFILEQ queue, PCWSTR src_root, PCWSTR src_path, PCWSTR src_file,
PCWSTR src_descr, PCWSTR src_tag, PCWSTR dst_dir, PCWSTR dst_file,
DWORD style )
{
SP_FILE_COPY_PARAMS_W params;
params.cbSize = sizeof(params);
params.QueueHandle = queue;
params.SourceRootPath = src_root;
params.SourcePath = src_path;
params.SourceFilename = src_file;
params.SourceDescription = src_descr;
params.SourceTagfile = src_tag;
params.TargetDirectory = dst_dir;
params.TargetFilename = dst_file;
params.CopyStyle = style;
params.LayoutInf = 0;
params.SecurityDescriptor = NULL;
return SetupQueueCopyIndirectW( ¶ms );
}
/***********************************************************************
* SetupQueueDefaultCopyA (SETUPAPI.@)
*/
BOOL WINAPI SetupQueueDefaultCopyA( HSPFILEQ queue, HINF hinf, PCSTR src_root, PCSTR src_file,
PCSTR dst_file, DWORD style )
{
SP_FILE_COPY_PARAMS_A params;
params.cbSize = sizeof(params);
params.QueueHandle = queue;
params.SourceRootPath = src_root;
params.SourcePath = NULL;
params.SourceFilename = src_file;
params.SourceDescription = NULL;
params.SourceTagfile = NULL;
params.TargetDirectory = NULL;
params.TargetFilename = dst_file;
params.CopyStyle = style;
params.LayoutInf = hinf;
params.SecurityDescriptor = NULL;
return SetupQueueCopyIndirectA( ¶ms );
}
/***********************************************************************
* SetupQueueDefaultCopyW (SETUPAPI.@)
*/
BOOL WINAPI SetupQueueDefaultCopyW( HSPFILEQ queue, HINF hinf, PCWSTR src_root, PCWSTR src_file,
PCWSTR dst_file, DWORD style )
{
SP_FILE_COPY_PARAMS_W params;
params.cbSize = sizeof(params);
params.QueueHandle = queue;
params.SourceRootPath = src_root;
params.SourcePath = NULL;
params.SourceFilename = src_file;
params.SourceDescription = NULL;
params.SourceTagfile = NULL;
params.TargetDirectory = NULL;
params.TargetFilename = dst_file;
params.CopyStyle = style;
params.LayoutInf = hinf;
params.SecurityDescriptor = NULL;
return SetupQueueCopyIndirectW( ¶ms );
}
/***********************************************************************
* SetupQueueDeleteA (SETUPAPI.@)
*/
BOOL WINAPI SetupQueueDeleteA( HSPFILEQ handle, PCSTR part1, PCSTR part2 )
{
struct file_queue *queue = handle;
struct file_op *op;
if (!(op = HeapAlloc( GetProcessHeap(), 0, sizeof(*op) ))) return FALSE;
op->style = 0;
op->src_root = NULL;
op->src_path = NULL;
op->src_file = NULL;
op->src_descr = NULL;
op->src_tag = NULL;
op->dst_path = strdupAtoW( part1 );
op->dst_file = strdupAtoW( part2 );
queue_file_op( &queue->delete_queue, op );
return TRUE;
}
/***********************************************************************
* SetupQueueDeleteW (SETUPAPI.@)
*/
BOOL WINAPI SetupQueueDeleteW( HSPFILEQ handle, PCWSTR part1, PCWSTR part2 )
{
struct file_queue *queue = handle;
struct file_op *op;
if (!(op = HeapAlloc( GetProcessHeap(), 0, sizeof(*op) ))) return FALSE;
op->style = 0;
op->src_root = NULL;
op->src_path = NULL;
op->src_file = NULL;
op->src_descr = NULL;
op->src_tag = NULL;
op->dst_path = strdupW( part1 );
op->dst_file = strdupW( part2 );
queue_file_op( &queue->delete_queue, op );
return TRUE;
}
/***********************************************************************
* SetupQueueRenameA (SETUPAPI.@)
*/
BOOL WINAPI SetupQueueRenameA( HSPFILEQ handle, PCSTR SourcePath, PCSTR SourceFilename,
PCSTR TargetPath, PCSTR TargetFilename )
{
struct file_queue *queue = handle;
struct file_op *op;
if (!(op = HeapAlloc( GetProcessHeap(), 0, sizeof(*op) ))) return FALSE;
op->style = 0;
op->src_root = NULL;
op->src_path = strdupAtoW( SourcePath );
op->src_file = strdupAtoW( SourceFilename );
op->src_descr = NULL;
op->src_tag = NULL;
op->dst_path = strdupAtoW( TargetPath );
op->dst_file = strdupAtoW( TargetFilename );
queue_file_op( &queue->rename_queue, op );
return TRUE;
}
/***********************************************************************
* SetupQueueRenameW (SETUPAPI.@)
*/
BOOL WINAPI SetupQueueRenameW( HSPFILEQ handle, PCWSTR SourcePath, PCWSTR SourceFilename,
PCWSTR TargetPath, PCWSTR TargetFilename )
{
struct file_queue *queue = handle;
struct file_op *op;
if (!(op = HeapAlloc( GetProcessHeap(), 0, sizeof(*op) ))) return FALSE;
op->style = 0;
op->src_root = NULL;
op->src_path = strdupW( SourcePath );
op->src_file = strdupW( SourceFilename );
op->src_descr = NULL;
op->src_tag = NULL;
op->dst_path = strdupW( TargetPath );
op->dst_file = strdupW( TargetFilename );
queue_file_op( &queue->rename_queue, op );
return TRUE;
}
/***********************************************************************
* SetupQueueCopySectionA (SETUPAPI.@)
*/
BOOL WINAPI SetupQueueCopySectionA( HSPFILEQ queue, PCSTR src_root, HINF hinf, HINF hlist,
PCSTR section, DWORD style )
{
UNICODE_STRING sectionW;
BOOL ret = FALSE;
if (!RtlCreateUnicodeStringFromAsciiz( §ionW, section ))
{
SetLastError( ERROR_NOT_ENOUGH_MEMORY );
return FALSE;
}
if (!src_root)
ret = SetupQueueCopySectionW( queue, NULL, hinf, hlist, sectionW.Buffer, style );
else
{
UNICODE_STRING srcW;
if (RtlCreateUnicodeStringFromAsciiz( &srcW, src_root ))
{
ret = SetupQueueCopySectionW( queue, srcW.Buffer, hinf, hlist, sectionW.Buffer, style );
RtlFreeUnicodeString( &srcW );
}
else SetLastError( ERROR_NOT_ENOUGH_MEMORY );
}
RtlFreeUnicodeString( §ionW );
return ret;
}
/***********************************************************************
* SetupQueueCopySectionW (SETUPAPI.@)
*/
BOOL WINAPI SetupQueueCopySectionW( HSPFILEQ queue, PCWSTR src_root, HINF hinf, HINF hlist,
PCWSTR section, DWORD style )
{
SP_FILE_COPY_PARAMS_W params;
LPWSTR security_key, security_descriptor = NULL;
INFCONTEXT context, security_context;
WCHAR dest[MAX_PATH], src[MAX_PATH];
INT flags;
DWORD required;
BOOL ret;
TRACE( "hinf=%p/%p section=%s root=%s\n",
hinf, hlist, debugstr_w(section), debugstr_w(src_root) );
/* Check for .Security section */
security_key = MyMalloc( (strlenW( section ) + strlenW( DotSecurity )) * sizeof(WCHAR) + sizeof(UNICODE_NULL) );
if (!security_key)
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return FALSE;
}
strcpyW( security_key, section );
strcatW( security_key, DotSecurity );
ret = SetupFindFirstLineW( hinf, security_key, NULL, &security_context );
MyFree(security_key);
if (ret)
{
if (!SetupGetLineText( &security_context, NULL, NULL, NULL, NULL, 0, &required ))
return FALSE;
security_descriptor = MyMalloc( required * sizeof(WCHAR) );
if (!security_descriptor)
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return FALSE;
}
if (!SetupGetLineText( &security_context, NULL, NULL, NULL, security_descriptor, required, NULL ))
{
MyFree( security_descriptor );
return FALSE;
}
}
params.cbSize = sizeof(params);
params.QueueHandle = queue;
params.SourceRootPath = src_root;
params.SourcePath = NULL;
params.SourceDescription = NULL;
params.SourceTagfile = NULL;
params.TargetFilename = dest;
params.CopyStyle = style;
params.LayoutInf = hinf;
params.SecurityDescriptor = security_descriptor;
ret = FALSE;
if (!hlist) hlist = hinf;
if (!hinf) hinf = hlist;
if (!SetupFindFirstLineW( hlist, section, NULL, &context )) goto done;
if (!(params.TargetDirectory = get_destination_dir( hinf, section ))) goto done;
do
{
if (!SetupGetStringFieldW( &context, 1, dest, sizeof(dest)/sizeof(WCHAR), NULL ))
goto done;
if (!SetupGetStringFieldW( &context, 2, src, sizeof(src)/sizeof(WCHAR), NULL )) *src = 0;
if (!SetupGetIntField( &context, 4, &flags )) flags = 0; /* FIXME */
params.SourceFilename = *src ? src : NULL;
if (!SetupQueueCopyIndirectW( ¶ms )) goto done;
} while (SetupFindNextLine( &context, &context ));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -