Menu

#620 Please make FS QUERY on Windows return the entry's case

STAFV3.3
closed-fixed
5
2009-09-18
2009-08-28
No

Please make FS QUERY on windows os return the actual case of the entry. currently it returns the case according to the case of the query issued. See https://sourceforge.net/forum/forum.php?thread_id=3376776&forum_id=104046 for details.

Discussion

  • Sharon Lucas

    Sharon Lucas - 2009-09-04
    • assigned_to: nobody --> slucas
    • summary: Please make FS QUERY on window return the entry's case --> Please make FS QUERY on Windows return the entry's case
     
  • Sharon Lucas

    Sharon Lucas - 2009-09-16

    This feature changes the "Name" value returned in the result from a FS QUERY ENTRY request on Windows so that it returns the actual path name in the right case and using Windows backslashes for paths and gets the full path name for relative paths and get the long path name for paths that use 8.3 short name.

    For example, when STAFProc is started from directory C:\dev (e.g. that's STAFProc's current directory), here are examples of FS QUERY ENTRY requests whose "Name" value in the result now reflects the full/long/case-sensitive path name

    C:\>STAF local FS QUERY ENTRY /PROGRA~1/MICROS~1
    Response
    --------
    Name : C:\Program Files\microsoft frontpage
    Link Target : <None>
    Type : D
    Size : 0
    Upper 32-bit Size : 0
    Lower 32-bit Size : 0
    Modified Date-Time: 20030217-10:02:20

    C:\>STAF local FS QUERY ENTRY C:
    Response
    --------
    Name : C:\dev
    Link Target : <None>
    Type : D
    Size : 0
    Upper 32-bit Size : 0
    Lower 32-bit Size : 0
    Modified Date-Time: 20090916-17:11:48

    C:\>STAF local FS QUERY ENTRY .\src\stax\..\Stax/Test.Xml
    Response
    --------
    Name : C:\dev\src\stax\test.xml
    Link Target : <None>
    Type : F
    Size : 1221
    Upper 32-bit Size : 0
    Lower 32-bit Size : 1221
    Modified Date-Time: 20030320-18:04:18

    C:\>STAF local FS QUERY ENTRY \\lucas\C$\dev\src\stax\..\Stax\Test.Xml
    Response
    --------
    Name : \\lucas\C$\dev\src\stax\test.xml
    Link Target : <None>
    Type : F
    Size : 1221
    Upper 32-bit Size : 0
    Lower 32-bit Size : 1221
    Modified Date-Time: 20030320-18:04:18

     
  • Sharon Lucas

    Sharon Lucas - 2009-09-17

    With the changes I'm making per this feature to the STAF File System code for Windows to handle case-sensitivity, full paths, and long names, this also fixes problems where STAF previously could not recognize if a file being copied to is already currently being read from. For example, using STAF V3.3.4, the following FS COPY request that copies a file to itself (but uses different case to specify the file name) fails with RC 18 (with lots of STAFTrace warning messages logged about write errors), instead of RC 19. More importantly, it erases the contents of the file being copied since it didn't realize that it's in use. For example, using STAF V3.3.4, the following FS COPY request that copies a file to itself fails with RC 18 and erases the content of the file being copied:

    C:\>STAF local FS COPY FILE C:/temp\copytest/STAFTest.xxx\ TOFILE c:/temp/copytest\staftest.xxx
    Error submitting request, RC: 18

    C:\>dir C:\temp\copytest
    Volume in drive C has no label.
    Volume Serial Number is 5CC0-9DEE

    Directory of C:\temp\copytest

    09/17/2009 04:13 PM 0 STAFTest.XXX
    1 File(s) 0 bytes
    0 Dir(s) 21,351,571,456 bytes free

    Now, with the changes I'm making for this feature, this FS COPY request fails with RC 19 (with additional info in the result) and the file being copied is not erased. For example:

    C:\>STAF local FS COPY FILE C:/temp\copytest/STAFTest.xxx\ TOFILE c:/temp/copytest\staftest.xxx
    Error submitting request, RC: 19
    Additional info
    ---------------
    Cannot write to file C:\temp\user\STAFTest.XXX at the same time this request is
    reading from it or if another copy request is currently reading or writing the file.

    C:\>dir c:\temp\copytest
    Volume in drive C has no label.
    Volume Serial Number is B0B7-F95A

    Directory of c:\temp\copytest

    09/17/2009 04:34p 34 STAFTest.XXX
    1 File(s) 34 bytes
    0 Dir(s) 21,193,653,760 bytes free

     
  • Sharon Lucas

    Sharon Lucas - 2009-09-18

    This feature will be in the next version of STAF, V3.3.5, planned to be available at the end of September 2009.

    Index: stafif/win32/STAFFileSystem.cpp

    RCS file: /cvsroot/staf/src/staf/stafif/win32/STAFFileSystem.cpp,v
    retrieving revision 1.26
    diff -r1.26 STAFFileSystem.cpp
    12a13
    > #include "STAFUtilWin32.h"
    160a162,230
    > // Retrieves the full path name for the specified path and if the path
    > // exists, converts it to its long form in the correct case and using a
    > // backslash as the file separator and returns the updated path.
    >
    > static STAFString getFullLongPath(const STAFString &thePath)
    > {
    > // Remove any trailing slashes (that are not also leading slashes)
    >
    > STAFString orgPath = removeTrailingSlashes(thePath);
    >
    > // The GetFullPathName() API is not supported for Windows 95/98
    >
    > if (!(STAFUtilWin32GetWinType() & kSTAFWin2KPlus))
    > return orgPath;
    >
    > // Retrieves the full path and file name of the specified file.
    > // Merges the name of the current drive and directory with a specified
    > // file name to determine the full path and file name of a specified file.
    > // Converts relative path names to absolute path names and resolves any .
    > // and .. in the path name.
    >
    > TCHAR buffer[4096] = TEXT("");
    > TCHAR** lppPart = {NULL};
    >
    > unsigned int length = GetFullPathName(
    > orgPath.toCurrentCodePage()->buffer(), 4096, buffer, lppPart);
    >
    > if (length == 0)
    > {
    > // cout << "GetFullPathName() failed for: " << orgPath << endl;
    > return orgPath;
    > }
    >
    > buffer[length] = 0; // Add the trailing null
    > STAFString path = STAFString(buffer);
    >
    > // If the path starts with a drive letter and it's not upper-case,
    > // convert it to upper case as GetLongPathName doesn't always do this
    >
    > if ((path.length() >= 2) &&
    > (path.subString(1, 1, STAFString::kChar) == sColon) &&
    > (path.subString(0, 1, STAFString::kChar) !=
    > path.subString(0, 1, STAFString::kChar).toUpperCase()))
    > {
    > path = path.subString(0, 1, STAFString::kChar).toUpperCase() +
    > path.subString(1, STAFString::kRemainder, STAFString::kChar);
    > }
    >
    > // If the path exists, converts the specified path to its long form
    > // and the correct case, and if the path contains "short" names, they
    > // will be expanded to the "long" name. For example:
    > // C:\PROGRA~1\MICROS~1 -> C:\Program Files\microsoft frontpage
    >
    > length = GetLongPathName(
    > path.toCurrentCodePage()->buffer(), buffer, 4096);
    >
    > if (length == 0)
    > {
    > // cout << "GetLongPathName() failed for: " << path << endl;
    > return path;
    > }
    >
    > buffer[length] = 0; // Add the trailing null
    > path = STAFString(buffer);
    >
    > return path;
    > }
    >
    >
    308a379,383
    > // Get the full path and, if the path exists, convert the path to the
    > // long path name in the correct case
    >
    > thePath = getFullLongPath(thePath);
    >
    389,392d463
    < // Remove any trailing slashes (that are not also leading slashes)
    <
    < thePath = removeTrailingSlashes(thePath);
    <
    508a580,583
    > // Get the full/long path name in the correct case
    >
    > thePath = getFullLongPath(thePath);
    >
    533,536d607
    < // Remove any trailing slashes (that are not also leading slashes)
    <
    < thePath = removeTrailingSlashes(thePath);
    <
    Index: stafproc/STAFFSService.cpp
    ===================================================================
    RCS file: /cvsroot/staf/src/staf/stafproc/STAFFSService.cpp,v
    retrieving revision 1.100
    diff -r1.100 STAFFSService.cpp
    2823c2823,2826
    < // Remove trailing slashes in the directory name, if any
    ---
    > // Convert the fromDir to the full long path name
    > // (e.g. with correct file separators, correct case if Windows,
    > // no unnecessary trailing slashes, etc)
    >
    3040a3044,3050
    > // Convert the toDirectory to the full long path name
    > // (e.g. with correct file separators, correct case if Windows,
    > // no unnecessary trailing slashes, etc)
    >
    > STAFFSPath toDirPath(resToDir);
    > resToDir = toDirPath.setRoot(toDirPath.root()).asString();
    >
    3061,3062c3071,3072
    < "Cannot write to a directory at the same time this "
    < "request is reading from it");
    ---
    > STAFString("Cannot write to directory ") + resToDir +
    > " at the same time this request is reading from it");
    3074,3075c3084,3086
    < kSTAFFileReadError, "Cannot read from a directory that "
    < "another copy request is currently writing to");
    ---
    > kSTAFFileReadError,
    > STAFString( "Cannot read from directory ") + fromDir +
    > " at the same time another copy request is writing to it");
    Index: stafproc/STAFProc.cpp
    ===================================================================
    RCS file: /cvsroot/staf/src/staf/stafproc/STAFProc.cpp,v
    retrieving revision 1.226
    diff -r1.226 STAFProc.cpp
    2604c2604,2613
    < unsigned int theDirectoryExists = STAFFSPath(toDirectory).exists();
    ---
    > // Convert the toDirectory to the full long path name
    > // (e.g. with correct file separators, correct case if Windows,
    > // no unnecessary trailing slashes, etc)
    >
    > STAFFSPath toDirPath = STAFFSPath(toDirectory);
    > toDirectory = toDirPath.setRoot(toDirPath.root()).asString();
    >
    > // Check if the toDirectory already exists
    >
    > unsigned int theDirectoryExists = toDirPath.exists();
    2686,2689c2695,2699
    < "Cannot write to a directory at the same time this request "
    < "is reading from it or if another copy request is currently "
    < "reading or writing to the directory.");
    <
    ---
    > STAFString("Cannot write to directory ") + toDirectory +
    > " at the same time this request is reading from it or if "
    > "another copy request is currently reading or writing to "
    > "the directory.");
    >
    3274,3275c3284,3286
    < // Remove trailing slashes, if any, in the file name
    < toFile = toPath.setRoot(toPath.root()).asString();
    ---
    > // Convert the file name to the full long path name
    > // (e.g. with correct file separators, correct case if Windows,
    > // no unnecessary trailing slashes, etc)
    3276a3288,3289
    > toFile = toPath.setRoot(toPath.root()).asString();
    >
    3293,3295c3306,3308
    < "Cannot write to a file at the same time this request is "
    < "reading from it or if another copy request is currently "
    < "reading or writing the file.");
    ---
    > STAFString("Cannot write to file ") + toFile + " at the same"
    > " time this request is reading from it or if another copy "
    > "request is currently reading or writing the file.");
    Index: test/STAFTest.xml
    ===================================================================
    RCS file: /cvsroot/staf/src/staf/test/STAFTest.xml,v
    retrieving revision 1.278
    diff -r1.278 STAFTest.xml
    3282c3282
    < "STAFResult['name'] and " +
    ---
    > "STAFResult['name'].endswith('STAFTest.XXX') and " +
    3294c3294
    < "STAFResult['name'] and " +
    ---
    > "STAFResult['name'].endswith('STAFTest.XXX') and " +
    3306c3306
    < "STAFResult['name'] and " +
    ---
    > "STAFResult['name'].endswith('user') and " +
    3573c3573
    < "STAFResult['name'] and " +
    ---
    > "STAFResult['name'].endswith('subdirB') and " +

     
  • Sharon Lucas

    Sharon Lucas - 2009-09-18
    • status: open --> closed-fixed
     

Log in to post a comment.