Skip to content

Commit

Permalink
Merge pull request #12 from cortex-command-community/development
Browse files Browse the repository at this point in the history
fix: target CCCP 6.0 to correctly validate filepaths in new Mods/Data…
  • Loading branch information
traunts authored Jun 3, 2024
2 parents 1f1e348 + 494531e commit 0b9655a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
25 changes: 19 additions & 6 deletions packages/server/src/services/fs.service.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { readdirSync, statSync } from 'fs';
import { join, relative } from 'path';
import { moduleDirectoryExtension } from 'shared';
import {
DATA_DIRECTORY,
MOD_DIRECTORY,
moduleDirectoryExtension,
} from 'shared';
import { WorkspaceFolder } from 'vscode-languageserver';
import { URI } from 'vscode-uri';
import { URI, Utils } from 'vscode-uri';

class FileSystemService {
public moduleFileList: string[] = [];
Expand All @@ -16,11 +20,20 @@ class FileSystemService {
public updateFileList(): void {
this.moduleFileList = [];
this.workspaces.forEach((folder) => {
const workspacePath = URI.parse(folder.uri).fsPath;
const workspaceFileList = this.getAllFiles(workspacePath);
const workspaceUri = URI.parse(folder.uri);

for (const file of workspaceFileList) {
this.moduleFileList.push(relative(workspacePath, file));
const dataPathUri = Utils.joinPath(workspaceUri, DATA_DIRECTORY);
const modsPathUri = Utils.joinPath(workspaceUri, MOD_DIRECTORY);

const workspaceDataFileList = this.getAllFiles(dataPathUri.fsPath);
const workspaceModFileList = this.getAllFiles(modsPathUri.fsPath);

for (const file of workspaceDataFileList) {
this.moduleFileList.push(relative(dataPathUri.fsPath, file));
}

for (const file of workspaceModFileList) {
this.moduleFileList.push(relative(modsPathUri.fsPath, file));
}
});
}
Expand Down
2 changes: 2 additions & 0 deletions packages/shared/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export * from './lib/Shared';

export * from './lib/fileExtensions';

export * from './lib/constants';
2 changes: 2 additions & 0 deletions packages/shared/src/lib/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const DATA_DIRECTORY = 'Data';
export const MOD_DIRECTORY = 'Mods';

0 comments on commit 0b9655a

Please sign in to comment.