EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Filename completion in VMounter

Also by EldoS: MsgConnect
Cross-platform protocol-independent communication framework for building peer-to-peer and client-server applications and middleware components.
Posted: 11/12/2013 13:36:33
by Andy Key (Standard support level)
Joined: 11/12/2013
Posts: 16

Windows 8.1 x64
Visual Studio Express Desktop 2013
Callback Filesystem 5rc2
VMounter sample

I suspect filename completion isn't working properly in this sample.

I fire up the sample, create storage and mount it as Z:
Then I go to a Command Prompt window.

If I
type z:<Tab>
it completes the filename correctly to z:testfile_1.txt
type z:\<Tab>
works fine too.

If I
type z:t<Tab>
it cannot complete the filename.
type z:\t<Tab>
also doesn't work either.

This of course works fine on any other drive.

Because the content is Unicode, it looks wrong when type'd from the
Command Prompt, but OK in Notepad - this had me confused for a minute.
The bug in Command Prompt "type" is worth noting.

{{{ Andy
Posted: 11/13/2013 01:51:43
by Volodymyr Zinin (Team)

Moved to HelpDesk for further investigation.
Posted: 11/13/2013 16:33:12
by Andy Key (Standard support level)
Joined: 11/12/2013
Posts: 16

Looking at the implementation of CbFsEnumerateDirectory in Samples/CPP/VMounter/Mounter.cpp, it is clear that wildcard matching is only implemented for "*".
An attempt to complete "t*" is not going to work, its going to look for an exact match of "t" followed by the character "*".
It seems like a limitation of the samples, not of CbFS itself.

So I think I need to find or write a proper function which essentially does a wildcard match, in the same way Windows normally does. ie: copes with "?" and "*", and the funny behavior with ".".

Would be nice if a helper like this would be provided in CbFS.
I bet a lot of people will reimplement it :-)

{{{ Andy
Posted: 11/14/2013 00:36:03
by Eugene Mayevski (Team)

It's a good idea to use Mapper for testing - it adds minimal own functionality so it's better suited for checking the source of the problems.

As for mask matching function, this seems to be a good idea and I've added it to the todo list.

Sincerely yours
Eugene Mayevski
Posted: 11/26/2013 16:25:04
by Andy Key (Standard support level)
Joined: 11/12/2013
Posts: 16

In the interest of being helpful, here is some code I threw together...
It just so happens that in my filesystem, FileName is always char[] - you can imagine the simple changes needed to make it work with TCHAR[].


// Mask     matches FileName(s)
// --------         -----------
// File.Ext         File.Ext, FILE.ext
// a?b              apb, aqb, a.b
// *.c              a.c, b.c
// x*y              xy, xAy, xAAy
// File.            File

static BOOLEAN FileNameMatchesMask2(
        const char *FileName,
        LPCTSTR Mask,
        int MaskLength
        if ( MaskLength == 0 )
                return *FileName == 0;
        else if ( *Mask == _T('?') )
                return *FileName != 0 &&
                       FileNameMatchesMask2(FileName+1, Mask+1, MaskLength-1);
        else if ( *Mask == _T('*') )
                return ( *FileName != 0 &&
                         FileNameMatchesMask2(FileName+1, Mask, MaskLength) ) ||
                       FileNameMatchesMask2(FileName, Mask+1, MaskLength-1);
                return _totupper(*Mask) == toupper(*FileName) &&
                       FileNameMatchesMask2(FileName+1, Mask+1, MaskLength-1);

static BOOLEAN FileNameMatchesMask(
        const char *FileName,
        LPCTSTR Mask
        int MaskLength = _tcslen(Mask);
        if ( MaskLength >= 1 && Mask[MaskLength-1] == _T('.') )
        return FileNameMatchesMask2(FileName, Mask, MaskLength);
Also by EldoS: Solid File System
A virtual file system that offers a feature-rich storage for application documents and data with built-in compression and encryption.



Topic viewed 1232 times

Number of guests: 1, registered members: 0, in total hidden: 0


Back to top

As of July 15, 2016 EldoS business operates as a division of /n software, inc. For more information, please read the announcement.

Got it!