codefori / codefori/vscode-ibmi

Add full CCSID via a unified getFileInfo component

Open
#3,130 1 comment 0 reactions 0 assignees View on GitHub
idea
Dominant language
TypeScript
Stars
418
Forks
160
Avg merge
4d 19h
Merged PRs (30d)
12

Description

## Feature Request: Unified `getFileInfo` Component for File Metadata with CCSID

### Summary
Create a new component that retrieves comprehensive file metadata including CCSID information in a single call for both IBM i source file members and IFS streamfiles, using appropriate IBM i APIs that expose CCSID and field-level attributes.

### Background

Currently, the extension retrieves file metadata through multiple separate API calls:
- **Member metadata**: `getMemberInfo()` via the `GETMBRINFO.SQL` component (wraps `QUSRMBRD`)
- **CCSID information**: `getAttributes()` using the PASE `attr` command for IFS files
- **Variant character handling**: Separate checks throughout the codebase

**Important limitation**: The current `QUSRMBRD` API used in `GETMBRINFO` does **not** return CCSID information for files or fields, which is critical for proper variant character handling.

This fragmented approach requires multiple round-trips to retrieve complete file information, and the lack of CCSID data at file-open time causes issues with variant character support.

### Proposed Solution

Create a new `getFileInfo` component that retrieves comprehensive file metadata in a single call, using the appropriate IBM i APIs:

#### Recommended API: `QUSLFLD` (List Fields)

**Primary recommendation**: Use the `QUSLFLD` API which:
- Returns all columns (fields) for a database file
- Includes **all field attributes including CCSID** for each field
- Is easier to implement than `QDBRTVFD`
- Provides consistent field-level metadata

**Alternative**: `QDBRTVFD` (Retrieve Database File Description)
- Returns both **File Format CCSID** and **individual field CCSID**
- More complex to implement but provides additional file-level information

#### Implementation Approach

**New SQL Component: `GETFILEINFO.SQL`**

Create a table function or stored procedure that wraps:
- `QUSLFLD` API for retrieving field information with CCSID attributes
- Continue using `QUSRMBRD` for member-level metadata (timestamps, description)
- For IFS files: Continue using PASE `attr` command for CCSID

**Suggested Return Type:**
```typescript
interface FileInfo {
// Member/File identification
library?: string;
file?: string;
name: string;
extension: string;
created?: Date;
changed?: Date;
description?: string;

// File-level attributes
ccsid: number; // File format CCSID
recordLength?: number; // For members/database files
fileType: 'member' | 'streamfile';
isSource: boolean;

// Field-level information (for database files)
fields?: Array<{
name: string;
type: string;
length: number;
decimal?: number;
ccsid?: number; // Field-specific CCSID
description?: string;
}>;

// For IFS files
path?: string;
size?: number;

// Additional metadata
asp?: string;
owner?: string;
}
```
This feature would particularly benefit external extensions that consume the Code for IBM i API and need to properly handle variant characters in syntax highlighting, code analysis, and transformation tools. The availability of CCSID information at file-open time is crucial for proper character encoding and variant character support throughout the IBM i development ecosystem.
Let me know if you want me to compose the wrapper for the QUSLFLD API for this feature of it is is no longer needed.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.