forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Shortname to LFN?

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Advanced Help for VDS 5 & Up
View previous topic :: View next topic  
Author Message
Garrett
Moderator Team


Joined: 04 Oct 2001
Posts: 2149
Location: A House

PostPosted: Sat Oct 04, 2003 9:38 am    Post subject: Shortname to LFN? Reply with quote

Does anyone know of a quick way to convert a shortname to long name?

The "SearchtreeforFile" example by CodeScript does this in a round
about way, but it takes a bit too much time to do it's job. I tried working
out some other api's, but just am not good at working with the api's yet,
so I'm hoping that maybe someone else has a way already that's quick
and effective at converting the shortname of a directory or file to long
name.

Thanks in advance,
-Garrett

_________________
'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.)
Back to top
View user's profile Send private message
CodeScript
Moderator Team


Joined: 08 Jun 2003
Posts: 1060
Location: India

PostPosted: Sat Oct 04, 2003 2:14 pm    Post subject: Reply with quote

Hi Garrett
Try This :
I just omitted this from Dirpathinfo example somehow.
I will add it to that later anyway.

Code:
#-----------------------------------------------------------------------------#
#                                                                             #
# Default script template - to change it edit <vdspath>\default.dsc           #
#                                                                             #
# Author: CodeScript                                                          #
#                                                                             #
# Copyright:                                                                  #
#                                                                             #
#-----------------------------------------------------------------------------#
#DEFINE FUNCTION,Longname
REM Make sure such a file exists
%A = @SHORTNAME(C:\testfolder with a long file name\New Text Document.txt)
INFO %A!
INFO  @LONGNAME(%A)!
EXIT

:Longname
LOADLIB kernel32
IF %1
%P = %1
%D = @FILL(256)
%A = @LIB(kernel32,GetLongPathNameA,int:,@ADDR("%P"),@ADDR("%D"),int:256)
%D = @ADJUST(%D)
END
FREELIB kernel32
EXIT %D

________________________________________________________________________________________

_________________
Regards
- CodeScript
Arrow Give your application a professional look with the VDSGUI Extension
Back to top
View user's profile Send private message Visit poster's website
Garrett
Moderator Team


Joined: 04 Oct 2001
Posts: 2149
Location: A House

PostPosted: Sat Oct 04, 2003 5:29 pm    Post subject: Reply with quote

Ohhhhhhhh Oh!@ Thank you CodeScript!!! Smile

That does the job so much quicker than what I was doing! Smile

Thank you! Thank you! Thank you! Thank you! Thank you!

-Garrett

_________________
'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.)
Back to top
View user's profile Send private message
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Sat Oct 04, 2003 5:34 pm    Post subject: Reply with quote

Nice work CodeScript. Very Happy
_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
CodeScript
Moderator Team


Joined: 08 Jun 2003
Posts: 1060
Location: India

PostPosted: Sat Oct 04, 2003 5:46 pm    Post subject: Reply with quote

Thanks for the comments Very Happy
_________________
Regards
- CodeScript
Arrow Give your application a professional look with the VDSGUI Extension
Back to top
View user's profile Send private message Visit poster's website
Garrett
Moderator Team


Joined: 04 Oct 2001
Posts: 2149
Location: A House

PostPosted: Sat Oct 04, 2003 7:36 pm    Post subject: Reply with quote

You don't know how much of a time saver that was for me. I was using
your searchforfirstfile api. I was having to write a blank file to a directory
and then using that api to find it just so I could get the LFN for the
directory, and you know that api can take some time to search for the file,
especially if you have to loop through it several times doing this for
several directories.

I owe you one for posting this LFN api for me. Smile

-Garrett

_________________
'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.)
Back to top
View user's profile Send private message
Tommy
Admin Team


Joined: 16 Nov 2002
Posts: 746
Location: The Netherlands

PostPosted: Sat Oct 04, 2003 8:36 pm    Post subject: Reply with quote

Another approach would be this one:

Code:
info @file(c:\progra~1,D)
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Garrett
Moderator Team


Joined: 04 Oct 2001
Posts: 2149
Location: A House

PostPosted: Sat Oct 04, 2003 10:01 pm    Post subject: Reply with quote

CodeScript.... Is there anyreason this api would not work on XP? I can't
get it to work on XP.. Works like a charm on 9x though.

Tommy,

Try this:

Code:
 info @file(C:\PROGRA~1\COMMON~1,D)


and see if it gives you a full lfn from that.

-Garrett

_________________
'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.)
Back to top
View user's profile Send private message
PGWARE
Web Host


Joined: 29 Dec 2001
Posts: 1565

PostPosted: Sat Oct 04, 2003 10:36 pm    Post subject: Reply with quote

Just tried CodeScripts code on Windows XP Home on a box that was just reformated 2 hours ago and it works perfectly. Returns the full path.
Back to top
View user's profile Send private message
Tommy
Admin Team


Joined: 16 Nov 2002
Posts: 746
Location: The Netherlands

PostPosted: Sun Oct 05, 2003 12:39 am    Post subject: Reply with quote

I think an approach like this one would work too:

Code:
  %%path = C:\PROGRA~1\COMMON~1
  gosub shorttolongdir
  info %%result

  exit
:shorttolong
  if @equal(@substr(%%path,@len(%%path)),\)
    %%path = @strdel(%%path,@len(%%path))
  end
  %p = @pos("\",%%path)
  %%result = @substr(%%path,1,@pred(%p))
  %%dir = @substr(%%path,@succ(%p),@len(%%path))
 
  while @greater(@pos("\",%%dir),0)
    %p = @pos("\",%%dir)
    %%result = %%result"\"@substr(%%dir,1,@pred(%p))
    %%result = @file(%%result,D)
    %%dir = @strdel(%%dir,1,%p)
  wend
  %%result = %%result"\"%%dir
  exit
:shorttolongdir
  gosub shorttolong
  %%result = @file(%%result,D)
  exit
:shorttolongfile
  gosub shorttolong
  %%result = @file(%%result)
  exit
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Garrett
Moderator Team


Joined: 04 Oct 2001
Posts: 2149
Location: A House

PostPosted: Sun Oct 05, 2003 1:47 am    Post subject: Reply with quote

Apologies to CodeScript and Tommy.....

Both your codes work. It was my fault that they didn't work on XP. I
overlooked a difference in output from the command line and when I used
substr() to get the shortname of the directory, on XP, I was getting other
data before the directory path, which of course cause both codes to not
give a proper return.

Thank you both for your help and code. Smile

-Garrett

_________________
'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.)
Back to top
View user's profile Send private message
vdsalchemist
Admin Team


Joined: 23 Oct 2001
Posts: 1448
Location: Florida, USA

PostPosted: Sun Oct 05, 2003 4:30 am    Post subject: Reply with quote

Hi Garrett,
I gave you this ability with Gadget a long time ago. Also note that I did not use the API that CodeScript mentioned because there are some limitations to it. This is what MicroSoft had to say about the GetLongPathName API function....

Quote:
Windows NT and Windows 95: Include an additional header file called NewAPIs.h to make GetLongPathName available on these operating systems. The function is not implemented natively, but by a wrapper that utilizes other native functions on these systems. See the header file for details of the use of preprocessor directives that make the function available. If you do not have this header file, it can be obtained by downloading the most recent SDK from the SDK Update Site.


The function that I built with Gadget uses a similar method to this but does not use the GetLongPathName function. Also note that if the path is longer than 256 characters GetLongPathName will not work on Win9x and ME. This is another reason that I built a function myself... Anyway I just thought you should know this before you rolled out anything using GetLongPathName.

_________________
Home of

Give VDS a new purpose!
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Garrett
Moderator Team


Joined: 04 Oct 2001
Posts: 2149
Location: A House

PostPosted: Sun Oct 05, 2003 5:04 am    Post subject: Reply with quote

Johnny, thanks for the info... Sorry about forgetting the long file name
ability in Gadget.

-Garrett

_________________
'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.)
Back to top
View user's profile Send private message
vdsalchemist
Admin Team


Joined: 23 Oct 2001
Posts: 1448
Location: Florida, USA

PostPosted: Sun Oct 05, 2003 3:15 pm    Post subject: Reply with quote

Garrett,
It's no big deal. Just a reminder.

_________________
Home of

Give VDS a new purpose!
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Advanced Help for VDS 5 & Up All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group