[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Some path questions


Greetings, guys! Hope you all doing well.

So, I have a code:
--------------------------
Public Sub UpdateProgram()

Dim hClient As HttpClient
Dim rMatch As RegExp
Dim updatequestion As Integer
Dim prgURL, exeName As String

prgURL = "http://whatever";
exeName = "someprogram.gambas"

  hClient = New HttpClient As "hClient"
  hClient.URL = prgURL & exeName
  hClient.Async = False
  hClient.Timeout = 10
  hClient.Get(, "tmp.gambas")

If hClient.Status < 0 Then
    Return

Else
  If Not Exist(Application.Path & "/tmp.gambas") Then message("Due to some black magic the file is not downloaded")     rMatch = New RegExp(File.Load(Application.path & "/tmp.gambas"), "Version=(.*)\n")
    If rMatch[1].Text = Application.Version Then
      Try Kill "tmp.gambas"
      Return
    Else
      updatequestion = Message.Question("Version " & rMatch[1].Text & " is available", "Update", "Ignore")
      If updatequestion = 2 Or updatequestion = 3 Then
        Try Kill Application.Path & "/tmp.gambas"
        Return
      End If
      Move Application.Path & "/tmp.gambas" Kill Application.Path & "/" & exeName
      Chmod Application.Path & "/" & exeName To "rwxrwxrwx"
      Message("Version " & rMatch[1].Text & " installed. Please restart program")
      Quit
    End If
End If

End

-----------------------------
My question is about Application.Path. Why do I need it? What is the default path without it then. Why is it different for different operators? I mean, why hClient is downloading a file right into the program working directory, which is nice, but then not Exist nor Kill don't see it? Where do they look by default? I mean Exist ("tmp.gambas") is false, yet the file is right there, where hClient has put it. Exist (Application.Path & "/tmp.gambas") is true, as it should, but why so complicated? Maybe I am overcomplicating things.

Dmitry


Follow-Ups:
Re: Some path questionsT Lee Davidson <t.lee.davidson@xxxxxxxxx>
Re: Some path questionsJussi Lahtinen <jussi.lahtinen@xxxxxxxxx>
Re: Some path questionsBenoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx>