blob: 780f7ee5e54d8cffcb27b44761ea857cc219bea3 [file] [log] [blame]
// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:io';
import 'package:path/path.dart' as path;
class Cache {
final Directory cacheDir = Directory('cache');
Directory getCreateCacheDirectory(String name) {
var dir = Directory(path.join(cacheDir.path, name));
if (!dir.existsSync()) {
dir.createSync(recursive: true);
}
return dir;
}
Directory get archivesDir => getCreateCacheDirectory('archives');
Directory get packagesDir => getCreateCacheDirectory('packages');
Directory get usageDir => getCreateCacheDirectory('usage');
}