v0.2.1 c0399be

gfileutils.go RawHistoryFolder

1// Package glib was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package glib
3
4import (
5	"github.com/ebitengine/purego"
6
7	"github.com/bnema/puregotk/pkg/core"
8)
9
10// Flags to pass to g_file_set_contents_full() to affect its safety and
11// performance.
12type FileSetContentsFlags int
13
14const (
15
16	// No guarantees about file consistency or durability.
17	//   The most dangerous setting, which is slightly faster than other settings.
18	GFileSetContentsNoneValue FileSetContentsFlags = 0
19	// Guarantee file consistency: after a crash,
20	//   either the old version of the file or the new version of the file will be
21	//   available, but not a mixture. On Unix systems this equates to an `fsync()`
22	//   on the file and use of an atomic `rename()` of the new version of the file
23	//   over the old.
24	GFileSetContentsConsistentValue FileSetContentsFlags = 1
25	// Guarantee file durability: after a crash, the
26	//   new version of the file will be available. On Unix systems this equates to
27	//   an `fsync()` on the file (if %G_FILE_SET_CONTENTS_CONSISTENT is unset), or
28	//   the effects of %G_FILE_SET_CONTENTS_CONSISTENT plus an `fsync()` on the
29	//   directory containing the file after calling `rename()`.
30	GFileSetContentsDurableValue FileSetContentsFlags = 2
31	// Only apply consistency and durability
32	//   guarantees if the file already exists. This may speed up file operations
33	//   if the file doesn’t currently exist, but may result in a corrupted version
34	//   of the new file if the system crashes while writing it.
35	GFileSetContentsOnlyExistingValue FileSetContentsFlags = 4
36)
37
38// A test to perform on a file using g_file_test().
39type FileTest int
40
41const (
42
43	// %TRUE if the file is a regular file
44	//     (not a directory). Note that this test will also return %TRUE
45	//     if the tested file is a symlink to a regular file.
46	GFileTestIsRegularValue FileTest = 1
47	// %TRUE if the file is a symlink.
48	GFileTestIsSymlinkValue FileTest = 2
49	// %TRUE if the file is a directory.
50	GFileTestIsDirValue FileTest = 4
51	// %TRUE if the file is executable.
52	GFileTestIsExecutableValue FileTest = 8
53	// %TRUE if the file exists. It may or may not
54	//     be a regular file.
55	GFileTestExistsValue FileTest = 16
56)
57
58// Values corresponding to @errno codes returned from file operations
59// on UNIX. Unlike @errno codes, GFileError values are available on
60// all systems, even Windows. The exact meaning of each code depends
61// on what sort of file operation you were performing; the UNIX
62// documentation gives more details. The following error code descriptions
63// come from the GNU C Library manual, and are under the copyright
64// of that manual.
65//
66// It's not very portable to make detailed assumptions about exactly
67// which errors will be returned from a given operation. Some errors
68// don't occur on some systems, etc., sometimes there are subtle
69// differences in when a system will report a given error, etc.
70type FileError int
71
72const (
73
74	// Operation not permitted; only the owner of
75	//     the file (or other resource) or processes with special privileges
76	//     can perform the operation.
77	GFileErrorExistValue FileError = 0
78	// File is a directory; you cannot open a directory
79	//     for writing, or create or remove hard links to it.
80	GFileErrorIsdirValue FileError = 1
81	// Permission denied; the file permissions do not
82	//     allow the attempted operation.
83	GFileErrorAccesValue FileError = 2
84	// Filename too long.
85	GFileErrorNametoolongValue FileError = 3
86	// No such file or directory. This is a "file
87	//     doesn't exist" error for ordinary files that are referenced in
88	//     contexts where they are expected to already exist.
89	GFileErrorNoentValue FileError = 4
90	// A file that isn't a directory was specified when
91	//     a directory is required.
92	GFileErrorNotdirValue FileError = 5
93	// No such device or address. The system tried to
94	//     use the device represented by a file you specified, and it
95	//     couldn't find the device. This can mean that the device file was
96	//     installed incorrectly, or that the physical device is missing or
97	//     not correctly attached to the computer.
98	GFileErrorNxioValue FileError = 6
99	// The underlying file system of the specified file
100	//     does not support memory mapping.
101	GFileErrorNodevValue FileError = 7
102	// The directory containing the new link can't be
103	//     modified because it's on a read-only file system.
104	GFileErrorRofsValue FileError = 8
105	// Text file busy.
106	GFileErrorTxtbsyValue FileError = 9
107	// You passed in a pointer to bad memory.
108	//     (GLib won't reliably return this, don't pass in pointers to bad
109	//     memory.)
110	GFileErrorFaultValue FileError = 10
111	// Too many levels of symbolic links were encountered
112	//     in looking up a file name. This often indicates a cycle of symbolic
113	//     links.
114	GFileErrorLoopValue FileError = 11
115	// No space left on device; write operation on a
116	//     file failed because the disk is full.
117	GFileErrorNospcValue FileError = 12
118	// No memory available. The system cannot allocate
119	//     more virtual memory because its capacity is full.
120	GFileErrorNomemValue FileError = 13
121	// The current process has too many files open and
122	//     can't open any more. Duplicate descriptors do count toward this
123	//     limit.
124	GFileErrorMfileValue FileError = 14
125	// There are too many distinct file openings in the
126	//     entire system.
127	GFileErrorNfileValue FileError = 15
128	// Bad file descriptor; for example, I/O on a
129	//     descriptor that has been closed or reading from a descriptor open
130	//     only for writing (or vice versa).
131	GFileErrorBadfValue FileError = 16
132	// Invalid argument. This is used to indicate
133	//     various kinds of problems with passing the wrong argument to a
134	//     library function.
135	GFileErrorInvalValue FileError = 17
136	// Broken pipe; there is no process reading from the
137	//     other end of a pipe. Every library function that returns this
138	//     error code also generates a 'SIGPIPE' signal; this signal
139	//     terminates the program if not handled or blocked. Thus, your
140	//     program will never actually see this code unless it has handled
141	//     or blocked 'SIGPIPE'.
142	GFileErrorPipeValue FileError = 18
143	// Resource temporarily unavailable; the call might
144	//     work if you try again later.
145	GFileErrorAgainValue FileError = 19
146	// Interrupted function call; an asynchronous signal
147	//     occurred and prevented completion of the call. When this
148	//     happens, you should try the call again.
149	GFileErrorIntrValue FileError = 20
150	// Input/output error; usually used for physical read
151	//    or write errors. i.e. the disk or other physical device hardware
152	//    is returning errors.
153	GFileErrorIoValue FileError = 21
154	// Operation not permitted; only the owner of the
155	//    file (or other resource) or processes with special privileges can
156	//    perform the operation.
157	GFileErrorPermValue FileError = 22
158	// Function not implemented; this indicates that
159	//    the system is missing some functionality.
160	GFileErrorNosysValue FileError = 23
161	// Does not correspond to a UNIX error code; this
162	//    is the standard "failed for unspecified reason" error code present
163	//    in all #GError error code enumerations. Returned if no specific
164	//    code applies.
165	GFileErrorFailedValue FileError = 24
166)
167
168var xBasename func(string) string
169
170// Gets the name of the file without any leading directory
171// components. It returns a pointer into the given file name
172// string.
173func Basename(FileNameVar string) string {
174
175	cret := xBasename(FileNameVar)
176
177	return cret
178}
179
180var xBuildFilename func(string, ...interface{}) string
181
182// Creates a filename from a series of elements using the correct
183// separator for the current platform.
184//
185// On Unix, this function behaves identically to `g_build_path
186// (G_DIR_SEPARATOR_S, first_element, ....)`.
187//
188// On Windows, it takes into account that either the backslash
189// (`\` or slash (`/`) can be used as separator in filenames, but
190// otherwise behaves as on UNIX. When file pathname separators need
191// to be inserted, the one that last previously occurred in the
192// parameters (reading from left to right) is used.
193//
194// No attempt is made to force the resulting filename to be an absolute
195// path. If the first element is a relative path, the result will
196// be a relative path.
197//
198// If you are building a path programmatically you may want to use
199// #GPathBuf instead.
200func BuildFilename(FirstElementVar string, varArgs ...interface{}) string {
201
202	cret := xBuildFilename(FirstElementVar, varArgs...)
203
204	return cret
205}
206
207var xBuildFilenameValist func(string, []interface{}) string
208
209// Creates a filename from a list of elements using the correct
210// separator for the current platform.
211//
212// Behaves exactly like g_build_filename(), but takes the path elements
213// as a va_list.
214//
215// This function is mainly meant for implementing other variadic arguments
216// functions.
217func BuildFilenameValist(FirstElementVar string, ArgsVar []interface{}) string {
218
219	cret := xBuildFilenameValist(FirstElementVar, ArgsVar)
220
221	return cret
222}
223
224var xBuildFilenamev func([]string) string
225
226// Creates a filename from a vector of elements using the correct
227// separator for the current platform.
228//
229// This function behaves exactly like g_build_filename(), but takes the path
230// elements as a string array, instead of varargs. This function is mainly
231// meant for language bindings.
232//
233// If you are building a path programmatically you may want to use
234// #GPathBuf instead.
235func BuildFilenamev(ArgsVar []string) string {
236
237	cret := xBuildFilenamev(ArgsVar)
238
239	return cret
240}
241
242var xBuildPath func(string, string, ...interface{}) string
243
244// Creates a path from a series of elements using @separator as the
245// separator between elements.
246//
247// At the boundary between two elements, any trailing occurrences of
248// separator in the first element, or leading occurrences of separator
249// in the second element are removed and exactly one copy of the
250// separator is inserted.
251//
252// Empty elements are ignored.
253//
254// The number of leading copies of the separator on the result is
255// the same as the number of leading copies of the separator on
256// the first non-empty element.
257//
258// The number of trailing copies of the separator on the result is
259// the same as the number of trailing copies of the separator on
260// the last non-empty element. (Determination of the number of
261// trailing copies is done without stripping leading copies, so
262// if the separator is `ABA`, then `ABABA` has 1 trailing copy.)
263//
264// However, if there is only a single non-empty element, and there
265// are no characters in that element not part of the leading or
266// trailing separators, then the result is exactly the original value
267// of that element.
268//
269// Other than for determination of the number of leading and trailing
270// copies of the separator, elements consisting only of copies
271// of the separator are ignored.
272func BuildPath(SeparatorVar string, FirstElementVar string, varArgs ...interface{}) string {
273
274	cret := xBuildPath(SeparatorVar, FirstElementVar, varArgs...)
275
276	return cret
277}
278
279var xBuildPathv func(string, []string) string
280
281// Behaves exactly like g_build_path(), but takes the path elements
282// as a string array, instead of variadic arguments.
283//
284// This function is mainly meant for language bindings.
285func BuildPathv(SeparatorVar string, ArgsVar []string) string {
286
287	cret := xBuildPathv(SeparatorVar, ArgsVar)
288
289	return cret
290}
291
292var xCanonicalizeFilename func(string, uintptr) string
293
294// Gets the canonical file name from @filename. All triple slashes are turned into
295// single slashes, and all `..` and `.`s resolved against @relative_to.
296//
297// Symlinks are not followed, and the returned path is guaranteed to be absolute.
298//
299// If @filename is an absolute path, @relative_to is ignored. Otherwise,
300// @relative_to will be prepended to @filename to make it absolute. @relative_to
301// must be an absolute path, or %NULL. If @relative_to is %NULL, it'll fallback
302// to g_get_current_dir().
303//
304// This function never fails, and will canonicalize file paths even if they don't
305// exist.
306//
307// No file system I/O is done.
308func CanonicalizeFilename(FilenameVar string, RelativeToVar *string) string {
309
310	RelativeToVarPtr := core.GStrdupNullable(RelativeToVar)
311	defer core.GFreeNullable(RelativeToVarPtr)
312
313	cret := xCanonicalizeFilename(FilenameVar, RelativeToVarPtr)
314
315	return cret
316}
317
318var xDirMakeTmp func(uintptr, **Error) string
319
320// Creates a subdirectory in the preferred directory for temporary
321// files (as returned by g_get_tmp_dir()).
322//
323// @tmpl should be a string in the GLib file name encoding containing
324// a sequence of six 'X' characters, as the parameter to g_mkstemp().
325// However, unlike these functions, the template should only be a
326// basename, no directory components are allowed. If template is
327// %NULL, a default template is used.
328//
329// Note that in contrast to g_mkdtemp() (and mkdtemp()) @tmpl is not
330// modified, and might thus be a read-only literal string.
331func DirMakeTmp(TmplVar *string) (string, error) {
332	var cerr *Error
333
334	TmplVarPtr := core.GStrdupNullable(TmplVar)
335	defer core.GFreeNullable(TmplVarPtr)
336
337	cret := xDirMakeTmp(TmplVarPtr, &cerr)
338
339	if cerr == nil {
340		return cret, nil
341	}
342	return cret, cerr
343
344}
345
346var xFileErrorFromErrno func(int) FileError
347
348// Gets a #GFileError constant based on the passed-in @err_no.
349//
350// For example, if you pass in `EEXIST` this function returns
351// %G_FILE_ERROR_EXIST. Unlike `errno` values, you can portably
352// assume that all #GFileError values will exist.
353//
354// Normally a #GFileError value goes into a #GError returned
355// from a function that manipulates files. So you would use
356// g_file_error_from_errno() when constructing a #GError.
357func FileErrorFromErrno(ErrNoVar int) FileError {
358
359	cret := xFileErrorFromErrno(ErrNoVar)
360
361	return cret
362}
363
364var xFileGetContents func(string, *[]byte, *uint, **Error) bool
365
366// Reads an entire file into allocated memory, with good error
367// checking.
368//
369// If the call was successful, it returns %TRUE and sets @contents to the file
370// contents and @length to the length of the file contents in bytes. The string
371// stored in @contents will be nul-terminated, so for text files you can pass
372// %NULL for the @length argument. If the call was not successful, it returns
373// %FALSE and sets @error. The error domain is %G_FILE_ERROR. Possible error
374// codes are those in the #GFileError enumeration. In the error case,
375// @contents is set to %NULL and @length is set to zero.
376func FileGetContents(FilenameVar string, ContentsVar *[]byte, LengthVar *uint) (bool, error) {
377	var cerr *Error
378
379	cret := xFileGetContents(FilenameVar, ContentsVar, LengthVar, &cerr)
380
381	if cerr == nil {
382		return cret, nil
383	}
384	return cret, cerr
385
386}
387
388var xFileOpenTmp func(uintptr, *string, **Error) int
389
390// Opens a file for writing in the preferred directory for temporary
391// files (as returned by g_get_tmp_dir()).
392//
393// @tmpl should be a string in the GLib file name encoding containing
394// a sequence of six 'X' characters, as the parameter to g_mkstemp().
395// However, unlike these functions, the template should only be a
396// basename, no directory components are allowed. If template is
397// %NULL, a default template is used.
398//
399// Note that in contrast to g_mkstemp() (and mkstemp()) @tmpl is not
400// modified, and might thus be a read-only literal string.
401//
402// Upon success, and if @name_used is non-%NULL, the actual name used
403// is returned in @name_used. This string should be freed with g_free()
404// when not needed any longer. The returned name is in the GLib file
405// name encoding.
406func FileOpenTmp(TmplVar *string, NameUsedVar *string) (int, error) {
407	var cerr *Error
408
409	TmplVarPtr := core.GStrdupNullable(TmplVar)
410	defer core.GFreeNullable(TmplVarPtr)
411
412	cret := xFileOpenTmp(TmplVarPtr, NameUsedVar, &cerr)
413
414	if cerr == nil {
415		return cret, nil
416	}
417	return cret, cerr
418
419}
420
421var xFileReadLink func(string, **Error) string
422
423// Reads the contents of the symbolic link @filename like the POSIX
424// `readlink()` function.
425//
426// The returned string is in the encoding used for filenames. Use
427// g_filename_to_utf8() to convert it to UTF-8.
428//
429// The returned string may also be a relative path. Use g_build_filename()
430// to convert it to an absolute path:
431//
432// |[<!-- language="C" -->
433// g_autoptr(GError) local_error = NULL;
434// g_autofree gchar *link_target = g_file_read_link ("/etc/localtime", &local_error);
435//
436// if (local_error != NULL)
437//
438//	g_error ("Error reading link: %s", local_error->message);
439//
440// if (!g_path_is_absolute (link_target))
441//
442//	{
443//	  g_autofree gchar *absolute_link_target = g_build_filename ("/etc", link_target, NULL);
444//	  g_free (link_target);
445//	  link_target = g_steal_pointer (&absolute_link_target);
446//	}
447//
448// ]|
449func FileReadLink(FilenameVar string) (string, error) {
450	var cerr *Error
451
452	cret := xFileReadLink(FilenameVar, &cerr)
453
454	if cerr == nil {
455		return cret, nil
456	}
457	return cret, cerr
458
459}
460
461var xFileSetContents func(string, []byte, int, **Error) bool
462
463// Writes all of @contents to a file named @filename. This is a convenience
464// wrapper around calling g_file_set_contents_full() with `flags` set to
465// `G_FILE_SET_CONTENTS_CONSISTENT | G_FILE_SET_CONTENTS_ONLY_EXISTING` and
466// `mode` set to `0666`.
467func FileSetContents(FilenameVar string, ContentsVar []byte, LengthVar int) (bool, error) {
468	var cerr *Error
469
470	cret := xFileSetContents(FilenameVar, ContentsVar, LengthVar, &cerr)
471
472	if cerr == nil {
473		return cret, nil
474	}
475	return cret, cerr
476
477}
478
479var xFileSetContentsFull func(string, []byte, int, FileSetContentsFlags, int, **Error) bool
480
481// Writes all of @contents to a file named @filename, with good error checking.
482// If a file called @filename already exists it will be overwritten.
483//
484// @flags control the properties of the write operation: whether it’s atomic,
485// and what the tradeoff is between returning quickly or being resilient to
486// system crashes.
487//
488// As this function performs file I/O, it is recommended to not call it anywhere
489// where blocking would cause problems, such as in the main loop of a graphical
490// application. In particular, if @flags has any value other than
491// %G_FILE_SET_CONTENTS_NONE then this function may call `fsync()`.
492//
493// If %G_FILE_SET_CONTENTS_CONSISTENT is set in @flags, the operation is atomic
494// in the sense that it is first written to a temporary file which is then
495// renamed to the final name.
496//
497// Notes:
498//
499//   - On UNIX, if @filename already exists hard links to @filename will break.
500//     Also since the file is recreated, existing permissions, access control
501//     lists, metadata etc. may be lost. If @filename is a symbolic link,
502//     the link itself will be replaced, not the linked file.
503//
504//   - On UNIX, if @filename already exists and is non-empty, and if the system
505//     supports it (via a journalling filesystem or equivalent), and if
506//     %G_FILE_SET_CONTENTS_CONSISTENT is set in @flags, the `fsync()` call (or
507//     equivalent) will be used to ensure atomic replacement: @filename
508//     will contain either its old contents or @contents, even in the face of
509//     system power loss, the disk being unsafely removed, etc.
510//
511//   - On UNIX, if @filename does not already exist or is empty, there is a
512//     possibility that system power loss etc. after calling this function will
513//     leave @filename empty or full of NUL bytes, depending on the underlying
514//     filesystem, unless %G_FILE_SET_CONTENTS_DURABLE and
515//     %G_FILE_SET_CONTENTS_CONSISTENT are set in @flags.
516//
517//   - On Windows renaming a file will not remove an existing file with the
518//     new name, so on Windows there is a race condition between the existing
519//     file being removed and the temporary file being renamed.
520//
521//   - On Windows there is no way to remove a file that is open to some
522//     process, or mapped into memory. Thus, this function will fail if
523//     @filename already exists and is open.
524//
525// If the call was successful, it returns %TRUE. If the call was not successful,
526// it returns %FALSE and sets @error. The error domain is %G_FILE_ERROR.
527// Possible error codes are those in the #GFileError enumeration.
528//
529// Note that the name for the temporary file is constructed by appending up
530// to 7 characters to @filename.
531//
532// If the file didn’t exist before and is created, it will be given the
533// permissions from @mode. Otherwise, the permissions of the existing file will
534// remain unchanged.
535func FileSetContentsFull(FilenameVar string, ContentsVar []byte, LengthVar int, FlagsVar FileSetContentsFlags, ModeVar int) (bool, error) {
536	var cerr *Error
537
538	cret := xFileSetContentsFull(FilenameVar, ContentsVar, LengthVar, FlagsVar, ModeVar, &cerr)
539
540	if cerr == nil {
541		return cret, nil
542	}
543	return cret, cerr
544
545}
546
547var xNewFileTest func(string, FileTest) bool
548
549// Returns %TRUE if any of the tests in the bitfield @test are
550// %TRUE. For example, `(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)`
551// will return %TRUE if the file exists; the check whether it's a
552// directory doesn't matter since the existence test is %TRUE. With
553// the current set of available tests, there's no point passing in
554// more than one test at a time.
555//
556// Apart from %G_FILE_TEST_IS_SYMLINK all tests follow symbolic links,
557// so for a symbolic link to a regular file g_file_test() will return
558// %TRUE for both %G_FILE_TEST_IS_SYMLINK and %G_FILE_TEST_IS_REGULAR.
559//
560// Note, that for a dangling symbolic link g_file_test() will return
561// %TRUE for %G_FILE_TEST_IS_SYMLINK and %FALSE for all other flags.
562//
563// You should never use g_file_test() to test whether it is safe
564// to perform an operation, because there is always the possibility
565// of the condition changing before you actually perform the operation,
566// see [TOCTOU](https://en.wikipedia.org/wiki/Time-of-check_to_time-of-use).
567//
568// For example, you might think you could use %G_FILE_TEST_IS_SYMLINK
569// to know whether it is safe to write to a file without being
570// tricked into writing into a different location. It doesn't work!
571//
572// |[<!-- language="C" -->
573//
574//	// DON'T DO THIS
575//	if (!g_file_test (filename, G_FILE_TEST_IS_SYMLINK))
576//	  {
577//	    fd = g_open (filename, O_WRONLY);
578//	    // write to fd
579//	  }
580//
581//	// DO THIS INSTEAD
582//	fd = g_open (filename, O_WRONLY | O_NOFOLLOW | O_CLOEXEC);
583//	if (fd == -1)
584//	  {
585//	    // check error
586//	    if (errno == ELOOP)
587//	      // file is a symlink and can be ignored
588//	    else
589//	      // handle errors as before
590//	  }
591//	else
592//	  {
593//	    // write to fd
594//	  }
595//
596// ]|
597//
598// Another thing to note is that %G_FILE_TEST_EXISTS and
599// %G_FILE_TEST_IS_EXECUTABLE are implemented using the access()
600// system call. This usually doesn't matter, but if your program
601// is setuid or setgid it means that these tests will give you
602// the answer for the real user ID and group ID, rather than the
603// effective user ID and group ID.
604//
605// On Windows, there are no symlinks, so testing for
606// %G_FILE_TEST_IS_SYMLINK will always return %FALSE. Testing for
607// %G_FILE_TEST_IS_EXECUTABLE will just check that the file exists and
608// its name indicates that it is executable, checking for well-known
609// extensions and those listed in the `PATHEXT` environment variable.
610func NewFileTest(FilenameVar string, TestVar FileTest) bool {
611
612	cret := xNewFileTest(FilenameVar, TestVar)
613
614	return cret
615}
616
617var xGetCurrentDir func() string
618
619// Gets the current directory.
620//
621// The returned string should be freed when no longer needed.
622// The encoding of the returned string is system defined.
623// On Windows, it is always UTF-8.
624//
625// Since GLib 2.40, this function will return the value of the "PWD"
626// environment variable if it is set and it happens to be the same as
627// the current directory.  This can make a difference in the case that
628// the current directory is the target of a symbolic link.
629func GetCurrentDir() string {
630
631	cret := xGetCurrentDir()
632
633	return cret
634}
635
636var xMkdirWithParents func(string, int) int
637
638// Create a directory if it doesn't already exist. Create intermediate
639// parent directories as needed, too.
640func MkdirWithParents(PathnameVar string, ModeVar int) int {
641
642	cret := xMkdirWithParents(PathnameVar, ModeVar)
643
644	return cret
645}
646
647var xMkdtemp func(string) string
648
649// Creates a temporary directory in the current directory.
650//
651// See the [`mkdtemp()`](man:mkdtemp(3)) documentation on most UNIX-like systems.
652//
653// The parameter is a string that should follow the rules for
654// mkdtemp() templates, i.e. contain the string "XXXXXX".
655// g_mkdtemp() is slightly more flexible than mkdtemp() in that the
656// sequence does not have to occur at the very end of the template.
657// The X string will be modified to form the name of a directory that
658// didn't exist.
659// The string should be in the GLib file name encoding. Most importantly,
660// on Windows it should be in UTF-8.
661//
662// If you are going to be creating a temporary directory inside the
663// directory returned by g_get_tmp_dir(), you might want to use
664// g_dir_make_tmp() instead.
665func Mkdtemp(TmplVar string) string {
666
667	cret := xMkdtemp(TmplVar)
668
669	return cret
670}
671
672var xMkdtempFull func(string, int) string
673
674// Creates a temporary directory in the current directory.
675//
676// See the [`mkdtemp()`](man:mkdtemp(3)) documentation on most UNIX-like systems.
677//
678// The parameter is a string that should follow the rules for
679// mkdtemp() templates, i.e. contain the string "XXXXXX".
680// g_mkdtemp_full() is slightly more flexible than mkdtemp() in that the
681// sequence does not have to occur at the very end of the template
682// and you can pass a @mode. The X string will be modified to form
683// the name of a directory that didn't exist. The string should be
684// in the GLib file name encoding. Most importantly, on Windows it
685// should be in UTF-8.
686//
687// If you are going to be creating a temporary directory inside the
688// directory returned by g_get_tmp_dir(), you might want to use
689// g_dir_make_tmp() instead.
690func MkdtempFull(TmplVar string, ModeVar int) string {
691
692	cret := xMkdtempFull(TmplVar, ModeVar)
693
694	return cret
695}
696
697var xMkstemp func(string) int
698
699// Opens a temporary file in the current directory.
700//
701// See the [`mkstemp()`](man:mkstemp(3)) documentation on most UNIX-like systems.
702//
703// The parameter is a string that should follow the rules for
704// mkstemp() templates, i.e. contain the string "XXXXXX".
705// g_mkstemp() is slightly more flexible than mkstemp() in that the
706// sequence does not have to occur at the very end of the template.
707// The X string will be modified to form the name of a file that
708// didn't exist. The string should be in the GLib file name encoding.
709// Most importantly, on Windows it should be in UTF-8.
710func Mkstemp(TmplVar string) int {
711
712	cret := xMkstemp(TmplVar)
713
714	return cret
715}
716
717var xMkstempFull func(string, int, int) int
718
719// Opens a temporary file in the current directory.
720//
721// See the [`mkstemp()`](man:mkstemp(3)) documentation on most UNIX-like systems.
722//
723// The parameter is a string that should follow the rules for
724// mkstemp() templates, i.e. contain the string "XXXXXX".
725// g_mkstemp_full() is slightly more flexible than mkstemp()
726// in that the sequence does not have to occur at the very end of the
727// template and you can pass a @mode and additional @flags. The X
728// string will be modified to form the name of a file that didn't exist.
729// The string should be in the GLib file name encoding. Most importantly,
730// on Windows it should be in UTF-8.
731func MkstempFull(TmplVar string, FlagsVar int, ModeVar int) int {
732
733	cret := xMkstempFull(TmplVar, FlagsVar, ModeVar)
734
735	return cret
736}
737
738var xPathGetBasename func(string) string
739
740// Gets the last component of the filename.
741//
742// If @file_name ends with a directory separator it gets the component
743// before the last slash. If @file_name consists only of directory
744// separators (and on Windows, possibly a drive letter), a single
745// separator is returned. If @file_name is empty, it gets ".".
746func PathGetBasename(FileNameVar string) string {
747
748	cret := xPathGetBasename(FileNameVar)
749
750	return cret
751}
752
753var xPathGetDirname func(string) string
754
755// Gets the directory components of a file name. For example, the directory
756// component of `/usr/bin/test` is `/usr/bin`. The directory component of `/`
757// is `/`.
758//
759// If the file name has no directory components "." is returned.
760// The returned string should be freed when no longer needed.
761func PathGetDirname(FileNameVar string) string {
762
763	cret := xPathGetDirname(FileNameVar)
764
765	return cret
766}
767
768var xPathIsAbsolute func(string) bool
769
770// Returns %TRUE if the given @file_name is an absolute file name.
771// Note that this is a somewhat vague concept on Windows.
772//
773// On POSIX systems, an absolute file name is well-defined. It always
774// starts from the single root directory. For example "/usr/local".
775//
776// On Windows, the concepts of current drive and drive-specific
777// current directory introduce vagueness. This function interprets as
778// an absolute file name one that either begins with a directory
779// separator such as "\Users\tml" or begins with the root on a drive,
780// for example "C:\Windows". The first case also includes UNC paths
781// such as "\\\\myserver\docs\foo". In all cases, either slashes or
782// backslashes are accepted.
783//
784// Note that a file name relative to the current drive root does not
785// truly specify a file uniquely over time and across processes, as
786// the current drive is a per-process value and can be changed.
787//
788// File names relative the current directory on some specific drive,
789// such as "D:foo/bar", are not interpreted as absolute by this
790// function, but they obviously are not relative to the normal current
791// directory as returned by getcwd() or g_get_current_dir()
792// either. Such paths should be avoided, or need to be handled using
793// Windows-specific code.
794func PathIsAbsolute(FileNameVar string) bool {
795
796	cret := xPathIsAbsolute(FileNameVar)
797
798	return cret
799}
800
801var xPathSkipRoot func(string) string
802
803// Returns a pointer into @file_name after the root component,
804// i.e. after the "/" in UNIX or "C:\" under Windows. If @file_name
805// is not an absolute path it returns %NULL.
806func PathSkipRoot(FileNameVar string) string {
807
808	cret := xPathSkipRoot(FileNameVar)
809
810	return cret
811}
812
813func init() {
814	core.SetPackageName("GLIB", "glib-2.0")
815	core.SetSharedLibraries("GLIB", []string{"libgobject-2.0.so.0", "libglib-2.0.so.0"})
816	var libs []uintptr
817	for _, libPath := range core.GetPaths("GLIB") {
818		lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
819		if err != nil {
820			panic(err)
821		}
822		libs = append(libs, lib)
823	}
824
825	core.PuregoSafeRegister(&xBasename, libs, "g_basename")
826	core.PuregoSafeRegister(&xBuildFilename, libs, "g_build_filename")
827	core.PuregoSafeRegister(&xBuildFilenameValist, libs, "g_build_filename_valist")
828	core.PuregoSafeRegister(&xBuildFilenamev, libs, "g_build_filenamev")
829	core.PuregoSafeRegister(&xBuildPath, libs, "g_build_path")
830	core.PuregoSafeRegister(&xBuildPathv, libs, "g_build_pathv")
831	core.PuregoSafeRegister(&xCanonicalizeFilename, libs, "g_canonicalize_filename")
832	core.PuregoSafeRegister(&xDirMakeTmp, libs, "g_dir_make_tmp")
833	core.PuregoSafeRegister(&xFileErrorFromErrno, libs, "g_file_error_from_errno")
834	core.PuregoSafeRegister(&xFileGetContents, libs, "g_file_get_contents")
835	core.PuregoSafeRegister(&xFileOpenTmp, libs, "g_file_open_tmp")
836	core.PuregoSafeRegister(&xFileReadLink, libs, "g_file_read_link")
837	core.PuregoSafeRegister(&xFileSetContents, libs, "g_file_set_contents")
838	core.PuregoSafeRegister(&xFileSetContentsFull, libs, "g_file_set_contents_full")
839	core.PuregoSafeRegister(&xNewFileTest, libs, "g_file_test")
840	core.PuregoSafeRegister(&xGetCurrentDir, libs, "g_get_current_dir")
841	core.PuregoSafeRegister(&xMkdirWithParents, libs, "g_mkdir_with_parents")
842	core.PuregoSafeRegister(&xMkdtemp, libs, "g_mkdtemp")
843	core.PuregoSafeRegister(&xMkdtempFull, libs, "g_mkdtemp_full")
844	core.PuregoSafeRegister(&xMkstemp, libs, "g_mkstemp")
845	core.PuregoSafeRegister(&xMkstempFull, libs, "g_mkstemp_full")
846	core.PuregoSafeRegister(&xPathGetBasename, libs, "g_path_get_basename")
847	core.PuregoSafeRegister(&xPathGetDirname, libs, "g_path_get_dirname")
848	core.PuregoSafeRegister(&xPathIsAbsolute, libs, "g_path_is_absolute")
849	core.PuregoSafeRegister(&xPathSkipRoot, libs, "g_path_skip_root")
850
851}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 102

↑↓ moveenter openesc close