Skip to content

Commit a0e5d7e

Browse files
committed
Link, SymLink & Others
1 parent d0d1abe commit a0e5d7e

1 file changed

Lines changed: 42 additions & 2 deletions

File tree

directoyr_fs.go

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,15 @@ func FilePutContents(path,data string) {
287287
FClose(f)
288288
}
289289

290+
291+
// FPuts - Alias of FWrite
292+
// Original : https://www.php.net/manual/en/function.fputs.php
293+
// This function is an alias of: FWrite()..
294+
func FPuts(f *os.File, data string) int {
295+
return FWrite(f,data)
296+
}
297+
298+
290299
// FWrite - Binary-safe file write
291300
// Original : https://www.php.net/manual/en/function.fwrite.php
292301
// fwrite() writes the contents of string to the file stream pointed to by handle.
@@ -314,11 +323,22 @@ func IsDir(path string) bool {
314323
return err == nil && fi.IsDir()
315324
}
316325

326+
// IsExecutable - Tells whether the filename is executable
327+
// Original : https://www.php.net/manual/en/function.is-executable.php
328+
// Tells whether the filename is executable.
329+
func IsExecutable(path string) bool {
330+
fi, err := os.Lstat(path)
331+
if err != nil {
332+
log.Fatal(err)
333+
}
334+
return fi.Mode()&0100 != 0
335+
}
336+
317337
// IsFile - Tells whether the filename is a regular file.
318338
// Original : https://www.php.net/manual/en/function.is-file.php
319339
// Tells whether the given file is a regular file.
320-
func IsFile(name string) bool{
321-
file, err := os.Stat(name)
340+
func IsFile(path string) bool{
341+
file, err := os.Stat(path)
322342
return err == nil && file.Mode().IsRegular()
323343
}
324344

@@ -355,6 +375,26 @@ func IsWriteable(path string) bool {
355375
return IsWritable(path)
356376
}
357377

378+
// Link - Create a hard link
379+
// Original : https://www.php.net/manual/en/function.link.php
380+
// link() creates a hard link.
381+
func Link(target, link string) {
382+
err := os.Link(target,link)
383+
if err != nil {
384+
log.Fatal(err)
385+
}
386+
}
387+
388+
// SymLink - Creates a symbolic link
389+
// Original : https://www.php.net/manual/en/function.symlink.php
390+
// symlink() creates a symbolic link to the existing target with the specified name link.
391+
func SymLink(target, link string) {
392+
err := os.Symlink(target, link)
393+
if err != nil {
394+
log.Fatal(err)
395+
}
396+
}
397+
358398
// MkDir - Makes directory.
359399
// Original : https://www.php.net/manual/en/function.mkdir.php
360400
// Attempts to create the directory specified by pathname.

0 commit comments

Comments
 (0)