Page 1 of 1 1
Topic Options
#173864 - 2007-02-12 09:58 PM Long variables value problem with Getfilesize and Getfiletime
Loren Offline
Lurker

Registered: 2003-07-29
Posts: 2
Getfilesize along with Getfilesize appear to have problems with having a long variable value passed to either function.

When either have a variable with long length passed to them they return nothing.
Same issue with kix2010.451 or kix2010.453


Sample code:

break on
cls
$v1="u:\user\projects\Documents\RATE CHG\Commercial Lines\200509190928 CIM Bldrs Risk Addl Ded - All states except AZ, GA, NM, and SC - Eff 12-01-05\200509191041 Model Hme deductibles AZ, GA, NM, SC - EFF 12-01-05|RE CIM Builders Risk additional deductibles (1005 project).msg"
? "get size"
? GetFileSize( $v1 )
? len(GetFileSize( $v1 ) )
? "get time "
? getfiletime($v1,1)
? len(getfiletime($v1,1))

Exit

Results were:
*************************************
get size

0
get time

0
*************************************
I’ve written a script that drills down through the directory tree and ran into this issue once the path started getting really long and was able to reproduce the issue with the sample code shown above.

I’ve looked through the forum and couldn’t find anything that related to getfiletime or getfilesize having problems with long variables being passed to them.


Ideas/suggestions would be appreciated.

Thank you.

Top
#173866 - 2007-02-12 10:18 PM Re: Long variables value problem with Getfilesize and Getfiletime [Re: Loren]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
Just quickly looking... I wonder if the pipe in your directory\file name is the problem?

EFF 12-01-05 | RE CIM Buil

Try removing it and see what your results are.

Top
#173868 - 2007-02-12 11:41 PM Re: Long variables value problem with Getfilesize and Getfiletime [Re: Allen]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
The Path Length is 271 chars. That is very long.
I have seen issues before with Excel not supporting paths longer then 218 characters, while the user could create a path of more then 220 characters. The only solution was to make the path shorter.
http://msdn2.microsoft.com/en-gb/library/zw949162(vs.80).aspx
I would not be surprised that this is not really a "problem" and all is just working "as designed".

Top
#173915 - 2007-02-14 06:36 PM Re: Long variables value problem with Getfilesize and Getfiletime [Re: Witto]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
I would bet on the pipe char issue as well...
_________________________
!

download KiXnet

Top
#173929 - 2007-02-15 12:49 AM Re: Long variables value problem with Getfilesize and Getfiletime [Re: Lonkero]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
I just made some text files in some directories with file names as long as possible. This is what I get:
 Code:
C:\12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901.txt
C:\1\1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890.txt
C:\1\2\3\123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456.txt
C:\1\2\3\4\5\6\7\8\9\0\1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012.txt

So in the root of C, I can make a path of 258 chars deep.
In a directory of the root, like C:\1, or a subdirectory, like C:\1\2, I can make a path of 259 chars deep.
As far as I know and as far as my knowledge goes, I do not succeed creating deeper paths, or I should create a mapped drive, like "P:\", referring to "\\server\share\deeper\".
 Code:
net use P: \\MyComputer\C$\1\2\3\4\5\6\7\8\9\0

The files I can create here:
 Code:
P:\12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901.txt
P:\1\1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890.txt
P:\1\2\3\123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456.txt
P:\1\2\3\4\5\6\7\8\9\0\1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012.txt

So by creating a mapped drive, I can create a path that is deeper than 258 or 259 chrs
OK, than I can create a script file that goes like this:
 Code:
If NOT @LOGONMODE
	Break On
Else
	Break Off
EndIf
Dim $RC

$RC = SetOption("Explicit", "On")
$RC = SetOption("NoMacrosInStrings", "On")
$RC = SetOption("NoVarsInStrings", "On")
$RC = SetOption("WrapAtEOL", "On")

;$RC = SetConsole("Hide")

$RC = "C:\12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901.txt"
"Size = " + GetFileSize($RC) ?
"Length = " + Len(GetFileSize($RC)) ?
"Time = " + GetFileTime($RC,1) ?
"Length time = " + Len(GetFileTime($RC,1)) ?
?
$RC = "C:\1\2\3\4\5\6\7\8\9\0\12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901.txt"
"Size = " + GetFileSize($RC) ?
"Length = " + Len(GetFileSize($RC)) ?
"Time = " + GetFileTime($RC,1) ?
"Length time = " + Len(GetFileTime($RC,1)) ?
?
"KiXtart = " + @SCRIPTEXE + " " + @kix ?

And here is the result
 Code:
Size = 100
Length = 3
Time = 2007/02/15 00:44:38
Length time = 19

Size =
Length = 0
Time =
Length time = 0

KiXtart = KIX32.EXE 4.53

IMHO, path is too long.
And pipe or "|" is an invalid char to create a file or dir name.

Top
#173947 - 2007-02-15 06:02 PM Re: Long variables value problem with Getfilesize and Getfiletime [Re: Witto]
Loren Offline
Lurker

Registered: 2003-07-29
Posts: 2
The pipe was an error on my part.

The “U:” drive was mapped to a network share.

I’ve done some more testing after reviewing the thread and have found by issuing a dir command from a command window, using the correct drive and path I received an error “The filename or Extension is too long.”

I then used the dir command with the /x option to generate the short names for the path and file, which produced:
U:\user\projects\DOCUME~1\RATECH~1\COMMER~1\2082F9~1\200509~1\RECIMB~1.MSG

When I changed the script to:

break on
cls
$v1="U:\user\projects\DOCUME~1\RATECH~1\COMMER~1\2082F9~1\200509~1\RECIMB~1.MSG "

? "get size"
? GetFileSize( $v1 )
? len(GetFileSize( $v1 ) )
? "get time "
? getfiletime($v1,1)
? len(getfiletime($v1,1))

exit

I received the expected results of:


get size
103936
6
get time
2005/09/19 09:43:00
19

I’ll be looking for &/or writing a UDF to convert longer paths and files to a short name.

Top
#173953 - 2007-02-15 07:09 PM Re: Long variables value problem with Getfilesize and Getfiletime [Re: Loren]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
You don't have to re-invent the wheel...

fnGetFileProp() - http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=84255&page=11#Post84255

Top
#173958 - 2007-02-16 12:07 AM Re: Long variables value problem with Getfilesize and Getfiletime [Re: Allen]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
I do apoligize for the long lines, but in this way, I try to show how long the lines exactly are.
Top
Page 1 of 1 1


Moderator:  ShaneEP, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 846 anonymous users online.
Newest Members
StuTheCoder, M_Moore, BeeEm, min_seow, Audio
17884 Registered Users

Generated in 0.063 seconds in which 0.025 seconds were spent on a total of 13 queries. Zlib compression enabled.