JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
juce_CommonFile_linux.cpp
Go to the documentation of this file.
1 /*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 The code included in this file is provided under the terms of the ISC license
11 http://www.isc.org/downloads/software-support-policy/isc-license. Permission
12 To use, copy, modify, and/or distribute this software for any purpose with or
13 without fee is hereby granted provided that the above copyright notice and
14 this permission notice appear in all copies.
15
16 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
17 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
18 DISCLAIMED.
19
20 ==============================================================================
21*/
22
23namespace juce
24{
25
26bool File::copyInternal (const File& dest) const
27{
28 FileInputStream in (*this);
29
30 if (dest.deleteFile())
31 {
32 {
33 FileOutputStream out (dest);
34
35 if (out.failedToOpen())
36 return false;
37
38 if (out.writeFromInputStream (in, -1) == getSize())
39 return true;
40 }
41
42 dest.deleteFile();
43 }
44
45 return false;
46}
47
52
53bool File::isHidden() const
54{
55 return getFileName().startsWithChar ('.');
56}
57
59{
61}
62
64{
65 constexpr int bufferSize = 8194;
66 HeapBlock<char> buffer (bufferSize);
67 auto numBytes = (int) readlink (getFullPathName().toRawUTF8(), buffer, bufferSize - 2);
68 return String::fromUTF8 (buffer, jmax (0, numBytes));
69}
70
71//==============================================================================
73{
74public:
75 Pimpl (const File& directory, const String& wc)
76 : parentDir (File::addTrailingSeparator (directory.getFullPathName())),
77 wildCard (wc), dir (opendir (directory.getFullPathName().toUTF8()))
78 {
79 }
80
81 ~Pimpl()
82 {
83 if (dir != nullptr)
84 closedir (dir);
85 }
86
87 bool next (String& filenameFound,
88 bool* const isDir, bool* const isHidden, int64* const fileSize,
89 Time* const modTime, Time* const creationTime, bool* const isReadOnly)
90 {
91 if (dir != nullptr)
92 {
93 const char* wildcardUTF8 = nullptr;
94
95 for (;;)
96 {
97 struct dirent* const de = readdir (dir);
98
99 if (de == nullptr)
100 break;
101
102 if (wildcardUTF8 == nullptr)
103 wildcardUTF8 = wildCard.toUTF8();
104
105 if (fnmatch (wildcardUTF8, de->d_name, FNM_CASEFOLD) == 0)
106 {
108
109 updateStatInfoForFile (parentDir + filenameFound, isDir, fileSize, modTime, creationTime, isReadOnly);
110
111 if (isHidden != nullptr)
112 *isHidden = filenameFound.startsWithChar ('.');
113
114 return true;
115 }
116 }
117 }
118
119 return false;
120 }
121
122private:
123 String parentDir, wildCard;
124 DIR* dir;
125
127};
128
129DirectoryIterator::NativeIterator::NativeIterator (const File& directory, const String& wildCardStr)
130 : pimpl (new DirectoryIterator::NativeIterator::Pimpl (directory, wildCardStr))
131{
132}
133
134DirectoryIterator::NativeIterator::~NativeIterator() {}
135
136bool DirectoryIterator::NativeIterator::next (String& filenameFound,
137 bool* isDir, bool* isHidden, int64* fileSize,
138 Time* modTime, Time* creationTime, bool* isReadOnly)
139{
140 return pimpl->next (filenameFound, isDir, isHidden, fileSize, modTime, creationTime, isReadOnly);
141}
142
143} // namespace juce
Holds a resizable array of primitive or copy-by-value objects.
Definition juce_Array.h:56
Wraps a pointer to a null-terminated UTF-8 character string, and provides various methods to operate ...
Represents a local file or directory.
Definition juce_File.h:45
bool isSymbolicLink() const
Returns true if this file is a link or alias that can be followed using getLinkedTarget().
bool isHidden() const
Returns true if this file is a hidden or system file.
static String addTrailingSeparator(const String &path)
Adds a separator character to the end of a path if it doesn't already have one.
int64 getSize() const
Returns the size of the file in bytes.
const String & getFullPathName() const noexcept
Returns the complete, absolute path of this file.
Definition juce_File.h:153
String getFileName() const
Returns the last section of the pathname.
static void findFileSystemRoots(Array< File > &results)
Creates a set of files to represent each file root.
String getNativeLinkedTarget() const
This returns the native path that the symbolic link points to.
Very simple container class to hold a pointer to some data on the heap.
The JUCE String class!
Definition juce_String.h:53
const char * toRawUTF8() const
Returns a pointer to a UTF-8 version of this string.
bool startsWithChar(juce_wchar character) const noexcept
Tests whether the string begins with a particular character.
static String fromUTF8(const char *utf8buffer, int bufferSizeBytes=-1)
Creates a String from a UTF-8 encoded buffer.
CharPointer_UTF8 toUTF8() const
Returns a pointer to a UTF-8 version of this string.
bool isNotEmpty() const noexcept
Returns true if the string contains at least one character.
Holds an absolute date and time.
Definition juce_Time.h:37
closedir
opendir
fnmatch
#define JUCE_DECLARE_NON_COPYABLE(className)
This is a shorthand macro for deleting a class's copy constructor and copy assignment operator.
typedef int
JUCE Namespace.
constexpr Type jmax(Type a, Type b)
Returns the larger of two values.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
Definition juce_Memory.h:88
long long int64
A platform-independent 64-bit integer type.
readdir
readlink