Files
Musify/lib/services/io_service.dart
2026-01-02 00:17:56 +04:00

58 lines
1.9 KiB
Dart

/*
* Copyright (C) 2026 Valeri Gokadze
*
* Musify is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Musify is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*
* For more information about Musify, including how to contribute,
* please visit: https://github.com/gokadzev/Musify
*/
import 'dart:io';
late String applicationDirPath;
class FilePaths {
// File extensions
static const String audioExtension = '.m4a';
static const String artworkExtension = '.jpg';
// Directory names
static const String tracksDir = 'tracks';
static const String artworksDir = 'artworks';
// Get full paths for various file types
static String getAudioPath(String songId) {
return '$applicationDirPath/$tracksDir/$songId$audioExtension';
}
static String getArtworkPath(String songId) {
return '$applicationDirPath/$artworksDir/$songId$artworkExtension';
}
// Ensure directories exist
static Future<void> ensureDirectoriesExist() async {
final tracksDirectory = Directory('$applicationDirPath/$tracksDir');
final artworksDirectory = Directory('$applicationDirPath/$artworksDir');
if (!await tracksDirectory.exists()) {
await tracksDirectory.create(recursive: true);
}
if (!await artworksDirectory.exists()) {
await artworksDirectory.create(recursive: true);
}
}
}