Compare commits

..

No commits in common. "15547f237b8542e1e92227644a424da6cbbeff3f" and "e6e88913d9c2c290ef723ab1ab30c106af367e1c" have entirely different histories.

2 changed files with 4 additions and 7 deletions

View File

@ -19,25 +19,22 @@ impl JsNCMFile {
/// Open NCM file. /// Open NCM file.
/// If everything is ok, return `0`. /// If everything is ok, return `0`.
/// If it needs more header bytes, return positive integer.
/// If it was not a valid NCM file, return -1.
/// ///
/// # Arguments /// # Arguments
/// ///
/// * `header`: Header bytes of NCM file. /// * `header`: Header bytes of NCM file.
/// ///
/// returns: Result<i32, JsError> /// returns: Result<usize, JsError>
/// ///
/// If it needs more bytes, the new header size will be returned. /// If it needs more bytes, the new header size will be returned.
/// If the header was large enough, it will return 0. /// If the header was large enough, it will return 0.
pub fn open(&mut self, header: &[u8]) -> Result<i32, JsError> { pub fn open(&mut self, header: &[u8]) -> Result<usize, JsError> {
match NCMFile::new(header) { match NCMFile::new(header) {
Ok(ncm) => { Ok(ncm) => {
self.ncm = Some(ncm); self.ncm = Some(ncm);
Ok(0) Ok(0)
} }
Err(NetEaseCryptoError::HeaderTooSmall(n)) => Ok(n as i32), Err(NetEaseCryptoError::HeaderTooSmall(n)) => Ok(n),
Err(NetEaseCryptoError::NotNCMFile) => Ok(-1),
Err(err) => Err(JsError::new(err.to_string().as_str())), Err(err) => Err(JsError::new(err.to_string().as_str())),
} }
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "@unlock-music/crypto", "name": "@unlock-music/crypto",
"version": "0.0.0-alpha.10", "version": "0.0.0-alpha.9",
"description": "Project Unlock Music: 加解密支持库", "description": "Project Unlock Music: 加解密支持库",
"scripts": { "scripts": {
"build": "node build.js", "build": "node build.js",