File: Main.module

package info (click to toggle)
gambas3 3.20.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 77,208 kB
  • sloc: ansic: 197,232; cpp: 124,273; sh: 18,999; javascript: 7,761; sql: 5,399; makefile: 2,358; perl: 1,397; xml: 490; python: 335
file content (32 lines) | stat: -rw-r--r-- 1,194 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
' Gambas module file

Private Const TemplateDbFileName As String = "db.sqlite"

Public Sub Main()
    DeployDbFile()
    FMain.Show
End

' This project contains the (initial) sqlite database file (db.sqlite) that contains the schema 
' and some example records. 
' To be able to write to this file, it has to be deloyed to a location where the current user 
' has write permissions. 
' For 'ordinary' applications this would be somewhere in Desktop.DataDir or in a user defined location. 
' For this tiny example I deploy to /tmp where the db file is cleaned up eventually.
Private Procedure DeployDbFile()
    Dim deployFilePath As String = GetDbDeployPath() &/ GetDbDeployFileName()
    If Not Exist(deployFilePath) Then 
        Copy Application.Path &/ TemplateDbFileName To deployFilePath
        Debug "Deployed sqlite database file to: ", deployFilePath
    Endif
End

'' Returns the path of the deploy directory. The directory of this path is guaranted to already exist.
Private Function GetDbDeployPath() As String
    Return "/tmp"
End

'' Returns the filename of the deployed database file
Private Function GetDbDeployFileName() As String
  Return Application.Name & ".sqlite"  
End