Jump to content

LFN UDF - overcome MAX_PATH limit of 256 chars


orbs
 Share

Recommended Posts

few bug fixes: updated at the first post.

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

  • 4 weeks later...

updated in first post.

modified functions:

_LFN_FileCopy() now allows additional flag to force raw copy of EFS files to unencrypted form.
_LFN_FileSetTime() fixed a bug with UTC
 
new functions: (for internal use mainly, but can be used by the calling script)
__LFN_FileGetAttribEx() is similar to FileGetAttrib() but also returns "E" for encrypted files.
__LFN_FileWritable() checks if a file is writable
 
renamed functions: (for internal consistency)
__LFN_SetUnicodePrefix() => __LFN_Target_SetUnicodePrefix()
__LFN_UnSetUnicodePrefix() => __LFN_Target_UnSetUnicodePrefix()
 
Edited by orbs

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

updated in first post.

modified functions:

_LFN_DirRemove() added a flag to clear Read-only & System attributes to ensure removal.

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

the conversion script is available - updated in first post.

- this script converts an existing AutoIt v3 Script to using the LFN UDF functions.
- best practice: put this script and the LFN UDF ("LFN.au3") in the same folder where your existing script is, and run the script from there.
- prior to the actual conversion process, the script displays a list of lines containing functions to be converted.
  information displayed: line number, current line, converted line.
  if you notice any undesirable changes this script is about to perform, you can abort the process now without any changes to your existing script.
- the line #include "LFN.au3" will be also added, after your last existing #include line, or at the top of your script. this is done only once.
- this script is designed for successive usage: if you have already converted a script with earlier version of the LFN UDF, and you have a newer version,
  then just run the conversion script again on the same scripts that were already converted.
- naturally, running this conversion script again on an already converted existing script (of the same LFN UDF major version) has no effect.
- a backup of your existing script is generated. for example:
  source file name: "YourScriptName.au3"
  backup file name: "YourScriptName.au3.PreLFN_YYYYMMDDhhmmss.au3"
- to revert the conversion, either use the generated backup, or follow these steps:
  1) search for the string "__LFN_" (note the two underscores before LFN) and replace any __LFN_* function with your own equivalent.
     this is needed only if you are using some functions of the LFN UDF that are for internal use only.
  2) search & replace the string _LFN_ with empty string.
  3) remove the line: #include "LFN.au3"
Edited by orbs

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

version 1.0 is fully tested, updated in first post. also updated he demo script to include all functions. changes:

modified: _LFN_DirCopy() handles invalid accidental flag 8:

rewritten: _LFN_FileGetLongName()

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

You're not getting a lot of love for this nice work. Well, I'll be nicking bits out of this, for sure!

;o) Cor

 

oh? i got one "like"! that's a plenty!  :)

anyways, back to business.

has anyone ever noticed that IniReadSection() is limited to 32KB? and - no surprise, of course - that native Ini* functions can't handle too long paths?

those never happen, say you? well, those rarely do happen. my unfortunate self had both happening a few days ago.

so, the now-obvious road has been taken. update the first post with a new version of the UDF that includes _LFN_Ini* functions, and an updated demo script. the conversion script remains unchanged; however, if you have already converted any of your scripts, then to make use of the new functions you'll need to run the conversion process again.

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

SmOke_N has a great INI UDF for over 32k: '?do=embed' frameborder='0' data-embedContent>>

Ian

My projects:

  • IP Scanner - Multi-threaded ping tool to scan your available networks for used and available IP addresses, shows ping times, resolves IPs in to host names, and allows individual IPs to be pinged.
  • INFSniff - Great technicians tool - a tool which scans DriverPacks archives for INF files and parses out the HWIDs to a database file, and rapidly scans the local machine's HWIDs, searches the database for matches, and installs them.
  • PPK3 (Persistent Process Killer V3) - Another for the techs - suppress running processes that you need to keep away, helpful when fighting spyware/viruses.
  • Sync Tool - Folder sync tool with lots of real time information and several checking methods.
  • USMT Front End - Front End for Microsoft's User State Migration Tool, including all files needed for USMT 3.01 and 4.01, 32 bit and 64 bit versions.
  • Audit Tool - Computer audit tool to gather vital hardware, Windows, and Office information for IT managers and field techs. Capabilities include creating a customized site agent.
  • CSV Viewer - Displays CSV files with automatic column sizing and font selection. Lines can also be copied to the clipboard for data extraction.
  • MyDirStat - Lists number and size of files on a drive or specified path, allows for deletion within the app.
  • 2048 Game - My version of 2048, fun tile game.
  • Juice Lab - Ecigarette liquid making calculator.
  • Data Protector - Secure notes to save sensitive information.
  • VHD Footer - Add a footer to a forensic hard drive image to allow it to be mounted or used as a virtual machine hard drive.
  • Find in File - Searches files containing a specified phrase.
Link to comment
Share on other sites

SmOke_N has a great INI UDF for over 32k: '?do=embed' frameborder='0' data-embedContent>>

Ian

 

nice catch! i'll see if i can... ehmm... "borrow" any useful stuff from there  :)

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

@ashleygon,

that's not quite the best first post in AutoIt forum.

1) you are promoting a paid software. although this is not formally forbidden here, it is not encouraged. luckily for you, you did not provide a direct link.

2) in your effort to promote the paid software, you failed to realize that the purpose and functionality of this UDF is completely different. this UDF intends to provide support for too long paths, not to eliminate them.

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

I tried this out on a script, pretty darned good!

I did notice one bug, in _LFN_FileGetVersion(), the second parameter should be optional, e.g..

Func _LFN_FileGetVersion($sFile, $sField="FileVersion")

;o) Cor

nothing is foolproof to the sufficiently talented fool..

Link to comment
Share on other sites

thanks! i will make the necessary correction:

note that the default value is not "FileVersion". see this script:

ConsoleWrite('blank: '&FileGetVersion(@AutoItExe,'')&@CR)
ConsoleWrite('not specified: '&FileGetVersion(@AutoItExe)&@CR)
ConsoleWrite('FileVersion: '&FileGetVersion(@AutoItExe,'FileVersion')&@CR)
ConsoleWrite('ProductVersion: '&FileGetVersion(@AutoItExe,'ProductVersion')&@CR)

the results are:

blank: 
not specified: 3.3.10.2
FileVersion: 3, 3, 10, 2
ProductVersion: 3, 3, 10, 2
 
so you see, when the parameter is not specified, the result is different than when "FileVersion" is specified.
 
i did not find the default parameter, so i will make correction to _LFN_FileGetVersion() to accommodate the "not specified" case. update will be available shortly.
 
EDIT: updated the UDF and the demo script in the first post.
Edited by orbs

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

Nice.

It seems the "not specified" version produces a more readable outpuf of FileVersion.  It also produces "0.0.0.0" when none is available. Handy.

;o) Cor

Edited by corz

nothing is foolproof to the sufficiently talented fool..

Link to comment
Share on other sites

A suggestion..

Some of these functions really slow things down (another reason why they should be handled natively by AutoIt); some of them are up to ten times slower!

I found myself adding sections like this..

Func _LFN_FileCopy($sSrc, $sDst, $iFlag = 0)

    if StringLen($sSrc) < 260 and StringLen($sDst) < 260 then
        return FileCopy($sSrc, $sDst, $iFlag)
    endif

Similarly inside _LFN_FileSetAttrib, _LFN_FileMove, etc..

;o) Cor

ps. "recourse" means "a turning or seeking for aid, safety, etc.e.g. to have recourse to the law". The word you are looking for is "recurse" (from "recursion") ;)

nothing is foolproof to the sufficiently talented fool..

Link to comment
Share on other sites

A suggestion..

I found myself adding sections like this..

Func _LFN_FileCopy($sSrc, $sDst, $iFlag = 0)

    if StringLen($sSrc) < 260 and StringLen($sDst) < 260 then
        return FileCopy($sSrc, $sDst, $iFlag)
    endif

 

good point, but...

the conditions you demonstrate are not completely suitable. first comes to mind is the need to check the length of file(src)+dst, in case the dst is a folder. also using wildcards trumpts this, as i need to list the files to get each's full length - and the body of the functions does it anyway. also unique flags need extra attention.

even considering these difficulties, it seems worth while to implement (some kind of) a "reversion" filter, so i'll be working on it.

 

ps. "recourse" means "a turning or seeking for aid, safety, etc.e.g. to have recourse to the law". The word you are looking for is "recurse" (from "recursion") ;)

 

i'll see if i can amend that without braking anything  ;)

 

I also notice that the IniWrite functions remove blank lines from the ini file. The results is a really squished up ini!

;o) Cor

 

yes, that's been coming across my way too. i'll get it fixed.

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

good point, but...

the conditions you demonstrate are not completely suitable. first comes to mind is the need to check the length of file(src)+dst, in case the dst is a folder. also using wildcards trumpts this, as i need to list the files to get each's full length - and the body of the functions does it anyway. also unique flags need extra attention.

even considering these difficulties, it seems worth while to implement (some kind of) a "reversion" filter, so i'll be working on it.

 

I did say "like". It was just a quick proof-of-concept.

At any rate, I'm not using wildcards with this function - all inputs are known file names and locations, but who knows what the future may bring!

I'm sure whatever you implement will be worthwhile - when dealing with millions of files, the speed differences can be staggering.

Thanks for retaining interest in this! No one else seems to care much!

;o) Cor

nothing is foolproof to the sufficiently talented fool..

Link to comment
Share on other sites

i follow with great interest on the threads in the "Developer Chat" forum. i did notice a comment that the LFN UDF functions require the unicode prefix; that is not so, and i added a note in the first post to clarify this point.

also apologies, that unfortunately i am rather busy at the moment, so updates to the UDF are on a slower progress rate. hopefully soon!  :)

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...