WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: stanl on September 24, 2013, 12:30:25 PM

Title: Hard Links
Post by: stanl on September 24, 2013, 12:30:25 PM
I vaguely remember some code posted to create Hard Links. Check on Tech DB, but didn't find anything initially. Is there any code pre-written?
Title: Re: Hard Links
Post by: td on September 24, 2013, 12:42:19 PM
You could shell-out and use mklink or use something like the following

Code (winbatch) Select

strNew = "C:\Temp2\HardLink.txt"
strExisting = "C:\Temp\Test.txt"
bResult = DllCall("Kernel32.dll", long:"CreateHardLinkA", lpstr:strNew, lpstr:strExisting, long:0)

if !bResult then Message("System Error", " Reported last error = ":DllLastError())
Title: Re: Hard Links
Post by: stanl on September 25, 2013, 10:17:38 AM
Thank you.
Title: Re: Hard Links
Post by: archimede on September 27, 2013, 06:03:51 AM
;==================================================================================================================================;
;                                                                                                                                  ;
; FUNZIONE COSTRUZIONE HARD LINK                                                                                                   ;
;                                                                                                                                  ;
;==================================================================================================================================;
;                                                                                                                                  ;
; Questa funzione genera un nuovo Hard Link corrispondente ad un Hard link esistente; in pratica genera un secondo nome di file    ;
; che punta agli stessi dati senza effettuare la copia del file stesso ( per chiarimenti vere informzioni specifiche sugli Hard    ;
; Links ).                                                                                                                         ;
;                                                                                                                                  ;
; Argomenti:                                                                                                                       ;
; sExistingLink         : Path completo di un Hard Link ( Nome File ) esistente da utilizzare come base                            ;
; sNewLink              : Path completo del nuovo Hard Link ( Nome File ) da generare che punterà agli stessi dati del link        ;
;                         puntati da sExistingLink                                                                                 ;
;                                                                                                                                  ;
; Ritorna:                                                                                                                         ;
; 0     Hard Link già esistente                                                                                                    ;
; 1     Hard Link generato                                                                                                         ;
; 2     Path non esistente                                                                                                         ;
;                                                                                                                                  ;
;==================================================================================================================================;

#DefineFunction HardLinkMake ( sExistingLink, sNewLink )
   Return DllCall("Kernel32.dll", long:"CreateHardLinkA", lpstr:sNewLink, lpstr:sExistingLink, long:0)
#EndFunction
Title: Re: Hard Links
Post by: DAG_P6 on September 28, 2013, 08:50:46 AM
Quote from: archimede on September 27, 2013, 06:03:51 AM
;==================================================================================================================================;
;                                                                                                                                  ;
; FUNZIONE COSTRUZIONE HARD LINK                                                                                                   ;
;                                                                                                                                  ;
;==================================================================================================================================;
;                                                                                                                                  ;
; Questa funzione genera un nuovo Hard Link corrispondente ad un Hard link esistente; in pratica genera un secondo nome di file    ;
; che punta agli stessi dati senza effettuare la copia del file stesso ( per chiarimenti vere informzioni specifiche sugli Hard    ;
; Links ).                                                                                                                         ;
;                                                                                                                                  ;
; Argomenti:                                                                                                                       ;
; sExistingLink         : Path completo di un Hard Link ( Nome File ) esistente da utilizzare come base                            ;
; sNewLink              : Path completo del nuovo Hard Link ( Nome File ) da generare che punterà agli stessi dati del link        ;
;                         puntati da sExistingLink                                                                                 ;
;                                                                                                                                  ;
; Ritorna:                                                                                                                         ;
; 0     Hard Link già esistente                                                                                                    ;
; 1     Hard Link generato                                                                                                         ;
; 2     Path non esistente                                                                                                         ;
;                                                                                                                                  ;
;==================================================================================================================================;

#DefineFunction HardLinkMake ( sExistingLink, sNewLink )
   Return DllCall("Kernel32.dll", long:"CreateHardLinkA", lpstr:sNewLink, lpstr:sExistingLink, long:0)
#EndFunction

Is the above WinBatch code Italian?
Title: Re: Hard Links
Post by: kdmoyers on September 30, 2013, 12:06:00 PM
Quote from: DAG_P6 on September 28, 2013, 08:50:46 AMIs the above WinBatch code Italian?
There's a great joke in there about Microsoft, but I can't seem to put my hands on it...
Title: Re: Hard Links
Post by: archimede on October 01, 2013, 05:47:04 AM
Yes, it's italian.
I made it for me (I'm Italian) and I copied like I made.
If you need I can translat for you; do you need it?
Title: Re: Hard Links
Post by: DAG_P6 on October 02, 2013, 05:55:00 AM
Quote from: archimede on October 01, 2013, 05:47:04 AM
Yes, it's italian.
I made it for me (I'm Italian) and I copied like I made.
If you need I can translat for you; do you need it?

Thank you very kindly for offering a translation.

However, I don't need it translated.

I asked the question because I was testing my skill at identifying the language in which it is written. I have read and used source code with comments and variable names in German, Spanish, Portuguese, and Swedish. Since I can read enough Italian to work out the essence of your comments, I don't need them translated.

It is amazing how far you can go with two years each of Latin and German, and one of Spanish, all taken in high school, over 40 years ago, and exposure to German and Spanish since then. Being able to use source codes with comments and names written in multiple spoken languages is a real Godsend.