Differenze tra le versioni di "Ottenere il nome di un file mediante le funzioni esterne del API di libgio"
Da Gambas-it.org - Wikipedia.
Riga 3: | Riga 3: | ||
E' possibile con alcune funzioni della libreria ''Libgio'' conoscere il nome di base di un file, ossia il nome essenziale del file comprensivo dell'estensione. | E' possibile con alcune funzioni della libreria ''Libgio'' conoscere il nome di base di un file, ossia il nome essenziale del file comprensivo dell'estensione. | ||
− | + | E' necessario avere installa nel sistema e richiamare la libreria dinamica condivisa: "''libgio-2.0.so''" | |
Riga 17: | Riga 17: | ||
' ''Gets the base name (the last component of the path) for a given GFile.''</font> | ' ''Gets the base name (the last component of the path) for a given GFile.''</font> | ||
Private Extern g_file_get_basename(gfile As Pointer) As String | Private Extern g_file_get_basename(gfile As Pointer) As String | ||
+ | |||
+ | <FONT Color=gray>' ''void g_object_unref (gpointer object)'' | ||
+ | ' ''Decreases the reference count of object.''</font> | ||
+ | Private Extern g_object_unref(gobject As Pointer) | ||
Riga 30: | Riga 34: | ||
Print s | Print s | ||
+ | |||
+ | g_object_unref(gf) | ||
'''End''' | '''End''' |
Versione delle 10:14, 17 feb 2018
La libreria Libgio fornisce un'astrazione del file system che permette alle applicazioni di accedere ai file locali e remoti.
E' possibile con alcune funzioni della libreria Libgio conoscere il nome di base di un file, ossia il nome essenziale del file comprensivo dell'estensione.
E' necessario avere installa nel sistema e richiamare la libreria dinamica condivisa: "libgio-2.0.so"
Mostriamo di seguito un semplice esempio pratico:
Library "libgio-2.0:0.4002.0" ' GFile * g_file_new_for_path (const char *path) ' Constructs a GFile for a given path. This operation never fails. Private Extern g_file_new_for_path(path As String) As Pointer ' char * g_file_get_basename (GFile *file) ' Gets the base name (the last component of the path) for a given GFile. Private Extern g_file_get_basename(gfile As Pointer) As String ' void g_object_unref (gpointer object) ' Decreases the reference count of object. Private Extern g_object_unref(gobject As Pointer) Public Sub Main() Dim gf As Pointer Dim s As String gf = g_file_new_for_path("/percorso/del/file") If IsNull(gf) Then Error.Raise("Impossibile creare un oggetto GFile con il percorso del file impostato !") s = g_file_get_basename(gf) Print s g_object_unref(gf) End