Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add extended file operation flags (FOFX_*) #1687

Closed
riverar opened this issue Aug 22, 2023 · 5 comments
Closed

Add extended file operation flags (FOFX_*) #1687

riverar opened this issue Aug 22, 2023 · 5 comments

Comments

@riverar
Copy link
Collaborator

riverar commented Aug 22, 2023

See shobjidl_core.idl

Proposed namespace: Windows.Win32.UI.Shell

// Extended FOF_ flags passed to IFileOperation::SetOperationFlags()
// These flags only work with IFileOperation not SHFileOperation.
// other posible FOF_ flags are specified in shellapi.h

cpp_quote("#define FOFX_NOSKIPJUNCTIONS         0x00010000  // Don't avoid binding to junctions (like Task folder, Recycle-Bin)")
cpp_quote("#define FOFX_PREFERHARDLINK          0x00020000  // Create hard link if possible")
cpp_quote("#define FOFX_SHOWELEVATIONPROMPT     0x00040000  // Show elevation prompts when error UI is disabled (use with FOF_NOERRORUI)")
cpp_quote("#define FOFX_RECYCLEONDELETE         0x00080000  // Recycle when deleting, rather than permanently deleting")
cpp_quote("#define FOFX_EARLYFAILURE            0x00100000  // Fail operation as soon as a single error occurs rather than trying to process other items (applies only when using FOF_NOERRORUI)")
cpp_quote("#define FOFX_PRESERVEFILEEXTENSIONS  0x00200000  // Rename collisions preserve file extns (use with FOF_RENAMEONCOLLISION)")
cpp_quote("#define FOFX_KEEPNEWERFILE           0x00400000  // Keep newer file on naming conflicts")
cpp_quote("#define FOFX_NOCOPYHOOKS             0x00800000  // Don't use copy hooks")
cpp_quote("#define FOFX_NOMINIMIZEBOX           0x01000000  // Don't allow minimizing the progress dialog")
cpp_quote("#define FOFX_MOVEACLSACROSSVOLUMES   0x02000000  // Copy security information when performing a cross-volume move operation")
cpp_quote("#define FOFX_DONTDISPLAYSOURCEPATH   0x04000000  // Don't display the path of source file in progress dialog")
cpp_quote("#define FOFX_DONTDISPLAYDESTPATH     0x08000000  // Don't display the path of destination file in progress dialog")
cpp_quote("#define FOFX_REQUIREELEVATION        0x10000000  // User expects the elevation; don't show a dialog to confirm")
cpp_quote("#define FOFX_ADDUNDORECORD           0x20000000  // This is a user-invoked operation, and should be placed on the undo stack.  This flag is preferred to FOF_ALLOWUNDO")
cpp_quote("#define FOFX_COPYASDOWNLOAD          0x40000000  // Show Downloading instead of Copying")
cpp_quote("#define FOFX_DONTDISPLAYLOCATIONS    0x80000000  // Hides the locations line in the progress dialog")
@riverar
Copy link
Collaborator Author

riverar commented Aug 23, 2023

@mikebattista Warning:

...
Windows.Win32.UI.Shell.FILEOPERATION_FLAGS.FOF_WANTNUKEWARNING added
Windows.Win32.UI.Shell.FILEOPERATION_FLAGS.FOFX_ADDUNDORECORD added
...

FOF flags are UInt16 and designed for use with SHFileOperation. FOFX flags are UInt32 and designed for use with IFileOperation::SetOperationFlags. We may want to create two separate enums to preserve those base types.

@mikebattista
Copy link
Contributor

That's not what the docs say.

@riverar
Copy link
Collaborator Author

riverar commented Aug 23, 2023

Isn't that always the case though? 🙃

Here's an extract from the headers:

// shellapi.h
typedef WORD FILEOP_FLAGS;

typedef struct _SHFILEOPSTRUCTW
{
    HWND            hwnd;
    UINT            wFunc;
    PCZZWSTR        pFrom;
    PCZZWSTR        pTo;
    FILEOP_FLAGS    fFlags;
    BOOL            fAnyOperationsAborted;
    LPVOID          hNameMappings;
    PCWSTR          lpszProgressTitle; // only used if FOF_SIMPLEPROGRESS
} SHFILEOPSTRUCTW, *LPSHFILEOPSTRUCTW;

(This is why extended flags exist and are only compatible with the newer COM API.)

@mikebattista
Copy link
Contributor

I optimized for the newer COM API which accepts DWORD. We can add AssociatedEnum to this older struct.

@riverar
Copy link
Collaborator Author

riverar commented Aug 23, 2023

I think by doing that, we'll be subtly indicating to projections that they can pass 32-bit integers through to SHFileOperation which is not ABI correct (#1502 (comment)) and may cause hard to diagnose issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants